Refactor script building / add to gitignore / 2 new scripts
This commit is contained in:
13
scripts/local-remote.sh
Normal file
13
scripts/local-remote.sh
Normal file
@@ -0,0 +1,13 @@
|
||||
sshpass -p "${SERVER_PASSWORD}" \
|
||||
rsync -avzu --delete \
|
||||
--exclude .git \
|
||||
--exclude .vscode \
|
||||
--exclude .DS_Store \
|
||||
--exclude node_modules \
|
||||
--exclude vendor \
|
||||
--exclude storage \
|
||||
--exclude uploads \
|
||||
--exclude temp \
|
||||
--exclude cache \
|
||||
--exclude sitepress-multilingual-cms \
|
||||
-e ssh . "${SERVER_USER}@${SERVER_HOST}:${SERVER_PATH}"
|
||||
12
scripts/remote-local.sh
Normal file
12
scripts/remote-local.sh
Normal file
@@ -0,0 +1,12 @@
|
||||
sshpass -p "${SERVER_PASSWORD}" \
|
||||
rsync -avzu \
|
||||
--exclude .vscode \
|
||||
--exclude .DS_Store \
|
||||
--exclude node_modules \
|
||||
--exclude vendor \
|
||||
--exclude storage \
|
||||
--exclude uploads \
|
||||
--exclude temp \
|
||||
--exclude cache \
|
||||
--exclude sitepress-multilingual-cms \
|
||||
-e ssh "${SERVER_USER}@${SERVER_HOST}:${SERVER_PATH}" . # --exclude .git \
|
||||
5
scripts/sftp-watch.sh
Normal file
5
scripts/sftp-watch.sh
Normal file
@@ -0,0 +1,5 @@
|
||||
|
||||
echo "Syncing remote->local..."
|
||||
sh remote-local.sh
|
||||
|
||||
watchexec --debounce 500ms -w . "sh local-remote.sh"
|
||||
@@ -18,7 +18,7 @@ echo "Syncing public folder..."
|
||||
sshpass -p "$SERVER_PASSWORD" rsync -avz --progress \
|
||||
--exclude 'storage' \
|
||||
--exclude '.htaccess' \
|
||||
"$LOCAL_PUBLIC/" "$SERVER_USER@$SERVER_HOST:$SERVER_PATH/"
|
||||
"$LOCAL_PUBLIC/" "$SERVER_USER@$SERVER_HOST:$SERVER_PATHpublic/"
|
||||
|
||||
# Upload mix-manifest.json specifically (if not already synced)
|
||||
echo "Uploading mix-manifest.json..."
|
||||
@@ -40,7 +40,7 @@ upload_changes() {
|
||||
sshpass -p "$SERVER_PASSWORD" rsync -avz --progress \
|
||||
--exclude 'storage' \
|
||||
--exclude '.htaccess' \
|
||||
"$LOCAL_PUBLIC/" "$SERVER_USER@$SERVER_HOST:$SERVER_PATH/"
|
||||
"$LOCAL_PUBLIC/" "$SERVER_USER@$SERVER_HOST:$SERVER_PATHpublic/"
|
||||
|
||||
# Upload mix-manifest.json specifically
|
||||
echo "Uploading mix-manifest.json..."
|
||||
@@ -120,46 +120,38 @@ echo "{
|
||||
|
||||
echo -e "${GREEN}.vscode/sftp.json created successfully${NC}"
|
||||
|
||||
# Add upload core build script
|
||||
# Add variables to upload core script
|
||||
echo "
|
||||
#!/bin/bash
|
||||
set -e
|
||||
# Go through scripts, add variables and add them to project folder
|
||||
scripts=("upload-core-build.sh" "watch-core-build.sh" "local-remote.sh" "remote-local.sh" "sftp-watch.sh")
|
||||
|
||||
# Configuration
|
||||
SERVER_USER=\"${USERNAME}\"
|
||||
SERVER_HOST=\"${HOST}\"
|
||||
SERVER_PASSWORD=\"${SSH_PASSWORD}\"
|
||||
SERVER_PATH=\"${SERVER_PROJECT_PATH}/public\" # Public folders location on server
|
||||
" > upload-core-build.sh
|
||||
for script in "${scripts[@]}"; do
|
||||
# Add variables to script
|
||||
echo "
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Append the rest of the upload core build script
|
||||
cat "${SCRIPT_DIR}/upload-core-build.sh" >> upload-core-build.sh
|
||||
# Configuration
|
||||
SERVER_USER=\"${USERNAME}\"
|
||||
SERVER_HOST=\"${HOST}\"
|
||||
SERVER_PASSWORD=\"${SSH_PASSWORD}\"
|
||||
SERVER_PATH=\"${SERVER_PROJECT_PATH}/\"
|
||||
" > "${script}"
|
||||
|
||||
echo -e "${GREEN}upload-core-build.sh created successfully${NC}"
|
||||
# Append the rest of the upload core build script
|
||||
cat "${SCRIPT_DIR}/scripts/${script}" >> "${script}"
|
||||
echo "${script} created successfully"
|
||||
|
||||
# Add watch core build script
|
||||
# Add variables to upload core script
|
||||
echo "
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Configuration
|
||||
SERVER_USER=\"${USERNAME}\"
|
||||
SERVER_HOST=\"${HOST}\"
|
||||
SERVER_PASSWORD=\"${SSH_PASSWORD}\"
|
||||
SERVER_PATH=\"${SERVER_PROJECT_PATH}/public\" # Public folders location on server
|
||||
" > watch-core-build.sh
|
||||
|
||||
# Append the rest of the watch core build script
|
||||
cat "${SCRIPT_DIR}/watch-core-build.sh" >> watch-core-build.sh
|
||||
|
||||
echo -e "${GREEN}watch-core-build.sh created successfully${NC}"
|
||||
# Add script to .gitignore
|
||||
echo "${script}" >> .gitignore
|
||||
echo -e "${BLUE}Added ${script} to .gitignore${NC}"
|
||||
done
|
||||
|
||||
# Upload lazygit to server
|
||||
echo "Uploading lazygit to server..."
|
||||
|
||||
cp "${SCRIPT_DIR}/lazygit" .
|
||||
sshpass -p "${SSH_PASSWORD}" scp "${SCRIPT_DIR}/lazygit" ${SERVER_HOST}:${SERVER_PROJECT_PATH}
|
||||
|
||||
echo -e "${GREEN}lazygit uploaded successfully${NC}"
|
||||
|
||||
# Add lazygit to .gitignore
|
||||
echo "lazygit" >> .gitignore
|
||||
echo -e "${BLUE}Added lazygit to .gitignore${NC}"
|
||||
|
||||
Reference in New Issue
Block a user