From 43c52017c78bbc67ec7a7ab3b690fdf2ffb0f98a Mon Sep 17 00:00:00 2001 From: Robert Alessi Date: Fri, 13 Dec 2019 16:09:44 +0100 Subject: new option to backup repositories --- x200-my.initd | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) (limited to 'x200-my.initd') diff --git a/x200-my.initd b/x200-my.initd index 8edefd6..b026b5b 100644 --- a/x200-my.initd +++ b/x200-my.initd @@ -1,14 +1,44 @@ #!/sbin/openrc-run -# Copyright 2018 Robert Alessi +# Copyright 2018-2019 Robert Alessi # Distributed under the terms of the GNU General Public License v2 -description="Removes whining noise from Thinkpads X200 and powers off the wifi on shutdown." +description="Removes whining noise from Thinkpads X200, powers off the wifi on shutdown and optionally backups directories." command="/usr/bin/intel_reg" pwmfreq="${PWMFREQ_RATE}" command_args="write 0x00061254 $pwmfreq" +extra_started_commands="initbackup" + +autobackup="${conf_autobackup}" +backup_path="${conf_backup_path}" +control_file="${conf_control_file}" +backup_cmd="/usr/bin/rsync" +backup_args="-aAX --relative --delete --quiet" + +do_listofpackages() { + /usr/bin/pacman -Qqetn > "$backup_path"/pkglist.txt + /usr/bin/pacman -Qqem > "$backup_path"/foreignpkglist.txt +} + +initbackup() { + if [ $autobackup = "true" ] + then + if [ -e "$backup_path"/"$control_file" ] + then + do_listofpackages + for dir in "${conf_backup_dirs[@]}" + do + if [ -d "$dir" ] + then + $backup_cmd $backup_args "$dir" "$backup_path" + fi + done + fi + fi +} + start() { if [ "${RC_CMD}" = "restart" ]; then @@ -20,4 +50,18 @@ start() { stop() { /usr/bin/nmcli radio all off + if [ $autobackup = "true" ] + then + if [ -e "$backup_path"/"$control_file" ] + then + do_listofpackages + for dir in "${conf_backup_dirs[@]}" + do + if [ -d "$dir" ] + then + $backup_cmd $backup_args "$dir" "$backup_path" + fi + done + fi + fi } -- cgit v1.2.3