Add fast option to script to create timers and services
This commit is contained in:
@@ -5,9 +5,30 @@ if [ "$EUID" -ne 0 ]; then
|
|||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ $# -gt 1 ]; then
|
||||||
|
echo "Usage: create-systemd-service-and-timer.sh [--fast]"
|
||||||
|
echo ""
|
||||||
|
echo "options:"
|
||||||
|
echo "--fast sets the backup script, log file and directory based on the name of the service"
|
||||||
|
echo ""
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Please enter the desired name for the service (e.g., backup). Can only contain [a-z, A-Z, 0-9]: "
|
echo "Please enter the desired name for the service (e.g., backup). Can only contain [a-z, A-Z, 0-9]: "
|
||||||
read SERVICE_NAME
|
read SERVICE_NAME
|
||||||
|
|
||||||
|
BAKUP_SCRIPT_PATH=""
|
||||||
|
LOG_FILE_PATH=""
|
||||||
|
WORKING_DIRECTORY=""
|
||||||
|
|
||||||
|
|
||||||
|
if [ "$1" = "--fast" ]; then
|
||||||
|
echo "Enter the name of the user where the service directory lives:"
|
||||||
|
read USER_NAME
|
||||||
|
BACKUP_SCRIPT_PATH="/home/$USER_NAME/$SERVICE_NAME/backup-$SERVICE_NAME.sh"
|
||||||
|
LOG_FILE_PATH="/home/$USER_NAME/$SERVICE_NAME/backup-$SERVICE_NAME.log"
|
||||||
|
WORKING_DIRECTORY="/home/$USER_NAME/$SERVICE_NAME"
|
||||||
|
else
|
||||||
echo "Please enter the path to your backup script (e.g., /home/user/service/backup.sh): "
|
echo "Please enter the path to your backup script (e.g., /home/user/service/backup.sh): "
|
||||||
read BACKUP_SCRIPT_PATH
|
read BACKUP_SCRIPT_PATH
|
||||||
|
|
||||||
@@ -16,6 +37,12 @@ read LOG_FILE_PATH
|
|||||||
|
|
||||||
echo "Please enter the working directory for the backup service (e.g., /home/user/service): "
|
echo "Please enter the working directory for the backup service (e.g., /home/user/service): "
|
||||||
read WORKING_DIRECTORY
|
read WORKING_DIRECTORY
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Using service name: $SERVICE_NAME"
|
||||||
|
echo "Using backup script path: $BACKUP_SCRIPT_PATH"
|
||||||
|
echo "Using log file path: $LOG_FILE_PATH"
|
||||||
|
echo "Using service working directory: $WORKING_DIRECTORY"
|
||||||
|
|
||||||
echo "Please enter the desired OnCalendar time for the timer (e.g.'Mon *-*-* 02:00:00'): "
|
echo "Please enter the desired OnCalendar time for the timer (e.g.'Mon *-*-* 02:00:00'): "
|
||||||
read ONCALENDAR_TIME
|
read ONCALENDAR_TIME
|
||||||
|
|||||||
Reference in New Issue
Block a user