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

47 lines
902 B
Bash
Raw Normal View History

2019-03-11 11:31:18 +01:00
# install script
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
}
# Inhalt von backup.service
function install_service {
# das HERE Document darf nicht eingerückt sein.
SERVICE=$(cat <<EOF
[Unit]
Description=Tägliches Wordpress Backup
[Service]
ExecStart=/bin/wp-backup.sh "$BACKUPFILE" "$BACKUPZIEL"
EOF
)
cp wp-backup.sh /bin/
cp backup.timer /etc/systemd/system/
echo "$SERVICE" > /etc/systemd/system/backup.service
systemctl enable --now backup.timer
}
#funktions aufrufe
dialog1
dialog2
install_service