Refactor script building / add to gitignore / 2 new scripts

This commit is contained in:
Leons Aleksandrovs
2025-11-14 22:57:27 +02:00
parent 95e6708713
commit a7f089e159
6 changed files with 57 additions and 35 deletions

13
scripts/local-remote.sh Normal file
View 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
View 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
View File

@@ -0,0 +1,5 @@
echo "Syncing remote->local..."
sh remote-local.sh
watchexec --debounce 500ms -w . "sh local-remote.sh"

View File

@@ -18,11 +18,11 @@ echo "Syncing public folder..."
sshpass -p "$SERVER_PASSWORD" rsync -avz --progress \ sshpass -p "$SERVER_PASSWORD" rsync -avz --progress \
--exclude 'storage' \ --exclude 'storage' \
--exclude '.htaccess' \ --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) # Upload mix-manifest.json specifically (if not already synced)
echo "Uploading mix-manifest.json..." echo "Uploading mix-manifest.json..."
sshpass -p "$SERVER_PASSWORD" scp "$LOCAL_MANIFEST" \ sshpass -p "$SERVER_PASSWORD" scp "$LOCAL_MANIFEST" \
"$SERVER_USER@$SERVER_HOST:$SERVER_PATH/mix-manifest.json" "$SERVER_USER@$SERVER_HOST:$SERVER_PATH/mix-manifest.json"
echo "Deployment complete!" echo "Deployment complete!"

View File

@@ -40,7 +40,7 @@ upload_changes() {
sshpass -p "$SERVER_PASSWORD" rsync -avz --progress \ sshpass -p "$SERVER_PASSWORD" rsync -avz --progress \
--exclude 'storage' \ --exclude 'storage' \
--exclude '.htaccess' \ --exclude '.htaccess' \
"$LOCAL_PUBLIC/" "$SERVER_USER@$SERVER_HOST:$SERVER_PATH/" "$LOCAL_PUBLIC/" "$SERVER_USER@$SERVER_HOST:$SERVER_PATHpublic/"
# Upload mix-manifest.json specifically # Upload mix-manifest.json specifically
echo "Uploading mix-manifest.json..." echo "Uploading mix-manifest.json..."

View File

@@ -120,46 +120,38 @@ echo "{
echo -e "${GREEN}.vscode/sftp.json created successfully${NC}" echo -e "${GREEN}.vscode/sftp.json created successfully${NC}"
# Add upload core build script # Go through scripts, add variables and add them to project folder
# Add variables to upload core script scripts=("upload-core-build.sh" "watch-core-build.sh" "local-remote.sh" "remote-local.sh" "sftp-watch.sh")
echo "
#!/bin/bash
set -e
# Configuration for script in "${scripts[@]}"; do
SERVER_USER=\"${USERNAME}\" # Add variables to script
SERVER_HOST=\"${HOST}\" echo "
SERVER_PASSWORD=\"${SSH_PASSWORD}\" #!/bin/bash
SERVER_PATH=\"${SERVER_PROJECT_PATH}/public\" # Public folders location on server set -e
" > upload-core-build.sh
# Append the rest of the upload core build script # Configuration
cat "${SCRIPT_DIR}/upload-core-build.sh" >> upload-core-build.sh 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 script to .gitignore
# Add variables to upload core script echo "${script}" >> .gitignore
echo " echo -e "${BLUE}Added ${script} to .gitignore${NC}"
#!/bin/bash done
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}"
# Upload lazygit to server # Upload lazygit to server
echo "Uploading lazygit to server..." echo "Uploading lazygit to server..."
cp "${SCRIPT_DIR}/lazygit" . cp "${SCRIPT_DIR}/lazygit" .
sshpass -p "${SSH_PASSWORD}" scp "${SCRIPT_DIR}/lazygit" ${SERVER_HOST}:${SERVER_PROJECT_PATH} sshpass -p "${SSH_PASSWORD}" scp "${SCRIPT_DIR}/lazygit" ${SERVER_HOST}:${SERVER_PROJECT_PATH}
echo -e "${GREEN}lazygit uploaded successfully${NC}"
echo -e "${GREEN}lazygit uploaded successfully${NC}" # Add lazygit to .gitignore
echo "lazygit" >> .gitignore
echo -e "${BLUE}Added lazygit to .gitignore${NC}"