Files
facinus/scripts/generate_scripts.sh
2025-04-06 21:13:17 +03:00

51 lines
1.4 KiB
Bash
Executable File

#!/bin/bash
# Generate client deployment scripts
DEPLOY_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deploy"
generate_client_scripts() {
echo "Generating client deployment scripts..."
generate_main_client_script
generate_obfuscated_script
generate_presets
}
generate_main_client_script() {
# Copy the script to the server
sudo cp "$DEPLOY_DIR/y" "$SERVER_ROOT"
# Replace placeholders in the script
sed -i "s|SERVER_PLACEHOLDER|$SERVER_IP|g" "$SERVER_ROOT/y"
sed -i "s|TOKEN_PLACEHOLDER|$SECRET_TOKEN|g" "$SERVER_ROOT/y"
sudo chmod 644 "$SERVER_ROOT/y"
}
generate_obfuscated_script() {
echo "Creating obfuscated version of the client script..."
# Base64 encode the script to obfuscate it
base64 -w0 < "$DEPLOY_DIR/y" > "$DEPLOY_DIR/y.b64"
sed -i "s|BASE64_PLACEHOLDER|$(cat "$DEPLOY_DIR/y.b64")|g" "$DEPLOY_DIR/x"
sudo cp "$DEPLOY_DIR/x" "$SERVER_ROOT/"
sudo chmod 644 "$SERVER_ROOT/x"
echo "Obfuscated script created."
}
generate_presets() {
echo "Creating installation presets..."
# Replace placeholders
for preset in "$DEPLOY_DIR/minimal" "$DEPLOY_DIR/full" "$DEPLOY_DIR/quiet"; do
sed -i "s|SERVER_PLACEHOLDER|$SERVER_IP|g" "$preset"
sudo cp "$preset" "$SERVER_ROOT/"
sudo chmod 644 "$SERVER_ROOT/$(basename "$preset")"
done
echo "Installation presets created."
}