3 ####################################################
7 ## returns the next available file name given a file
8 ## in the form /etc/backup.d/10.sys
9 ## sets variable $returned_filename
13 dir=`dirname $next_filename`
14 file=`basename $next_filename`
17 while [ -f $next_filename ]; do
19 next_filename="$dir/$number.$suffix"
24 ## installs packages (passed in as $@) if not present
28 installed=`dpkg -s $pkg | grep 'ok installed'`
29 if [ -z "$installed" ]; then
30 booleanBox "install $pkg?" "This backup action requires package $pkg. Do you want to install it now?"
33 echo "hit return to continue...."
41 defaultchoice="red is.pretty on"
42 choices="green is_nice_too off blue i_love_blue off yellow is.bright off orange make.me.hungry off"
43 radioBox "radio title" "choose one color" $defaultchoice $choices
46 1) echo "color choice cancelled..."; sleep 1;;
47 255) echo "something went wrong, exiting..."
51 msgBox "message title" "you said $result."
55 menuBox "new action menu" "select an action to create" \
56 return "return to main menu" \
57 sys "general hardware and system info" \
58 mysql "mysql database backup" \
59 ldap "ldap database backup" \
60 rdiff "incremental filesystem backup"
66 "mysql") mysql_wizard;;
68 "rdiff") rdiff_wizard;;
74 booleanBox "remove action" "Are you sure you want to remove action file $1?"
82 echo "Hit return to continue..."
87 backupninja --test --run $1
88 echo "Hit return to continue..."
102 filename=`basename $1`
103 inputBox "rename action" "enter a new filename" $filename
104 mv $dir/$filename $dir/$REPLY
109 base=`basename $action`
110 if [ "${base##*.}" == "disabled" ]; then
116 menuBox "action menu" "$action $first" \
117 main "return to main menu" \
118 view "view configuration" \
119 xedit "launch external editor" \
120 $enable "$enable action" \
121 name "change the filename" \
122 run "run this action now" \
123 test "do a test run" \
124 kill "remove this action"
125 [ $? = 1 ] && return;
128 "view") dialog --textbox $action 0 0;;
129 "xedit") $EDITOR $action;;
130 "disable") do_disable $action; return;;
131 "enable") do_enable $action; return;;
132 "name") do_rename $action; return;;
133 "run") do_run $action;;
134 "test") do_run_test $action;;
135 "kill") do_rm_action $action; return;;
141 #####################################################
144 conffile="/etc/backupninja.conf"
145 if [ ! -r "$conffile" ]; then
146 echo "Configuration file $conffile not found."
149 scriptdir=`grep scriptdirectory $conffile | awk '{print $3}'`
150 if [ ! -n "$scriptdir" ]; then
151 echo "Cound not find entry 'scriptdirectory' in $conffile"
154 if [ ! -d "$scriptdir" ]; then
155 echo "Script directory $scriptdir not found."
158 configdirectory=`grep configdirectory $conffile | awk '{print $3}'`
159 if [ ! -n "$configdirectory" ]; then
160 echo "Cound not find entry 'configdirectory' in $conffile"
163 if [ ! -d "$configdirectory" ]; then
164 echo "Configuration directory $configdirectory not found."
168 . $scriptdir/easydialog.sh
170 if [ "$UID" != "0" ]; then
171 msgBox "warning" "ninjahelper must be run by root!"
175 for file in `find $scriptdir -follow -name '*.helper'`; do
179 setApplicationTitle "ninjahelper"
182 #####################################################
190 for file in `find $conf/etc/backup.d/ -type f | sort -n`; do
191 menulist="$menulist $i $file"
196 menuBox "main menu" "select an action to edit" $menulist \
197 new "create a new backup action" \
198 quit "leave ninjahelper"
200 [ $? = 1 -o $? = 255 ] && exit 0;
203 if [ "$choice" == "new" ]; then
205 elif [ "$choice" == "quit" ]; then
208 action=${actions[$choice]};
209 if [ -f "$action" ]; then
212 msgBox "error" "error: cannot find the file '$action'"