#!/bin/sh # # handle configuration file backup list backuplist="/etc/backup-config.list" tmp=/tmp/backup-config action="$1" file="${2--}" status=0 installed="$(apm list)" active="$(apm list-active)" case "$action" in l | list) sort -u $backuplist 2>/dev/null || status=1 ;; e | export) rm -rf $tmp sort -u $backuplist | while read file; do if [ -e $file ]; then mkdir -p $tmp${file%/*} ln -s $file $tmp$file || status=2 fi done mkdir $tmp/tmp apm list-active > $tmp/tmp/list_active_addons.conf tar -czhf $file -C $tmp . || status=1 rm -rf $tmp ;; a | analyse) if [ -f /tmp/$2 ]; then rm $3 for addon in $(cat /tmp/$2); do if ! echo "$active" | grep -q "^$addon$"; then echo $addon >> $3 elif ! echo "$installed" | grep -q "^$addon$"; then echo $addon >> $3 fi done if [ ! -f $3 ]; then echo "#### keine weiteren Addons im Backup vorhanden ####" >> $3 fi else echo "#### Es wurde kein Backupfile für Addons gefunden ! ####" > $3 fi || status=1 ;; i | import) tar -xzf $file -C / || status=1 ;; u | update) #Addons updaten for addon in $(cat $2); do apm install $addon --activate; done rmcp $2 || status=1 ;; A | Addonimport) tar -xzf $file -C /tmp || status=1 ;; a | add) echo "$file" >> $backuplist || status=1 ;; d | del) sed "/^$(echo "$file" | sed "s/\//\\\\\//g")$/d" -i $backuplist || status=1 ;; *) echo "Usage: ${0##*/} {list | export | import | update | Addonimport | analyse | add | del} [FILE_NAME]" ;; esac exit $status