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

50 lines
981 B
Bash
Raw Normal View History

2019-03-11 11:31:18 +01:00
# install script
2019-03-11 12:53:47 +01:00
# 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
)
2019-03-11 11:31:18 +01:00
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 {
2019-03-11 12:53:47 +01:00
cp wp-backup.sh /bin/ && \
cp backup.timer /etc/systemd/system/ && \
echo "$SERVICE" > /etc/systemd/system/backup.service && \
systemctl enable --now backup.timer || fail
2019-03-11 11:31:18 +01:00
}
2019-03-11 12:53:47 +01:00
function fail {
echo "Fehler!!"
exit 1
}
2019-03-11 11:31:18 +01:00
#funktions aufrufe
dialog1
dialog2
install_service
2019-03-11 12:53:47 +01:00
exit 0