linuxkurs/beispiele/17/wp-backup/install.sh

50 lines
981 B
Bash

# install script
# Inhalt von backup.service
# HERE Document https://ss64.com/bash/syntax-here.html
SERVICE=$(cat <<EOF
[Unit]
Description=Tägliches Wordpress Backup
[Service]
ExecStart=/bin/wp-backup.sh "$BACKUPFILE" "$BACKUPZIEL"
EOF
)
function dialog1 {
BACKUPFILE=$(whiptail --inputbox "Backup Dateiname ohne Endung " 8 78 Name --title "Dateiname" 3>&1 1>&2 2>&3)
check_exit_status
}
function dialog2 {
BACKUPZIEL=$(whiptail --inputbox "Backup Ziel?" 8 78 localhost --title "rsync Backupziel" 3>&1 1>&2 2>&3)
check_exit_status
}
function check_exit_status {
exitstatus=$?
if [ $exitstatus = 1 ]; then
echo "User selected Cancel."
exit 1
fi
}
function install_service {
cp wp-backup.sh /bin/ && \
cp backup.timer /etc/systemd/system/ && \
echo "$SERVICE" > /etc/systemd/system/backup.service && \
systemctl enable --now backup.timer || fail
}
function fail {
echo "Fehler!!"
exit 1
}
#funktions aufrufe
dialog1
dialog2
install_service
exit 0