This repository was archived by the owner on Oct 7, 2025. It is now read-only.
File tree Expand file tree Collapse file tree
roles/debian/apt_unattended_upgrades Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2525 force : true
2626 when : apt_unattended_upgrades.enable
2727
28- - name : Copy unattended-upgrades linotp configuration file .
28+ - name : Copy unattended-upgrades linotp APT hook script .
2929 ansible.builtin.template :
30- src : 79linotp-pre-backup .j2
31- dest : /etc/apt/apt.conf.d/79linotp-pre-backup
30+ src : linotp-apt-hook.sh .j2
31+ dest : /usr/local/sbin/linotp-apt-hook.sh
3232 owner : root
3333 group : root
34- mode : " 0644 "
34+ mode : " 0755 "
3535 force : true
3636 when :
3737 - apt_unattended_upgrades.enable
3838 - apt_unattended_upgrades.linotp
3939
4040- name : Copy unattended-upgrades linotp configuration file.
4141 ansible.builtin.template :
42- src : 80linotp-post-init .j2
43- dest : /etc/apt/apt.conf.d/80linotp-post-init
42+ src : 79linotp-pre-and-post .j2
43+ dest : /etc/apt/apt.conf.d/79linotp-pre-and-post
4444 owner : root
4545 group : root
4646 mode : " 0644"
Original file line number Diff line number Diff line change 1+ // r71691 Makes sure linotp database is backed up prior to upgrade.
2+ DPkg::Pre-Invoke { "/usr/local/sbin/linotp-apt-hook.sh"; };
3+ DPkg::Post-Invoke { "/usr/local/sbin/linotp-apt-hook.sh"; };
Load diff This file was deleted.
Load diff This file was deleted.
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ LOG=" /var/log/linotp-upgrade.log"
4+ BACKUP_DIR=" /home/deploy/linotp_dbbackups"
5+ CREDS=" /home/deploy/.mysql.creds"
6+
7+ if apt list --upgradable 2> /dev/null | grep -q ' ^linotp/' ; then
8+ echo " [linotp-pre] linotp will be upgraded. Backing up database..." | tee -a " $LOG "
9+ mkdir -p " $BACKUP_DIR "
10+ mysqldump --defaults-file=" $CREDS " linotp > " $BACKUP_DIR /linotp_backup_$( date +%F_%H-%M-%S) .sql" && \
11+ echo " [linotp-pre] Backup complete." | tee -a " $LOG " || \
12+ echo " [linotp-pre] WARNING: Backup failed!" | tee -a " $LOG "
13+ fi
14+
15+ if grep -q ' Upgrade: linotp:' /var/log/apt/history.log; then
16+ echo " [linotp-post] linotp was upgraded. Running database init..." | tee -a " $LOG "
17+ linotp init database && \
18+ echo " [linotp-post] linotp init database completed." | tee -a " $LOG " || \
19+ echo " [linotp-post] linotp init database failed!" | tee -a " $LOG "
20+ fi
You can’t perform that action at this time.
0 commit comments