diff options
author | intrigeri <intrigeri@boum.org> | 2005-08-09 20:55:58 +0000 |
---|---|---|
committer | intrigeri <intrigeri@boum.org> | 2005-08-09 20:55:58 +0000 |
commit | 540f7e0f7c34b7a366a80f68ee8ea4dd32c89ecc (patch) | |
tree | 0e51c5bc8f639a285d3c09115732bb21b78051ab | |
parent | 49dfbcb81f79772c2283a9637eee49616b0b5ac8 (diff) | |
download | backupninja-540f7e0f7c34b7a366a80f68ee8ea4dd32c89ecc.tar.gz backupninja-540f7e0f7c34b7a366a80f68ee8ea4dd32c89ecc.tar.bz2 |
ninjahelper: better check_perms(), improved xedit.
-rw-r--r-- | changelog | 6 | ||||
-rwxr-xr-x | ninjahelper | 30 |
2 files changed, 31 insertions, 5 deletions
@@ -20,6 +20,12 @@ version XX -- ... now checks if the specified vserver is running. now checks if $PGSQLDUMP/$PGSQLDUMPALL are available where needed. now checks if "postgres" user exists on the host/vserver. + changes to ninjahelper + check_perms() does not die anymore on group/world readable + helper scripts (now consistent with the "helper scripts + must not be group or world writable!" error msg). + xedit action now tries $EDITOR, then /etc/alternatives/editor, + then nano, vim and vi, and aborts if none of these exists. version 0.7 -- July 26 2005 added ninjahelper: a dialog based wizard for creating backupninja configs. diff --git a/ninjahelper b/ninjahelper index aedeaf5..817b47b 100755 --- a/ninjahelper +++ b/ninjahelper @@ -6,11 +6,12 @@ function check_perms() { local file=$1 local perms=`ls -ld $file` - perms=${perms:4:6} - if [[ "$perms" != "------" && "$perms" != "r--r--" ]]; then + group_w_perm=${perms:5:1} + world_w_perm=${perms:8:1} + if [ "$group_w_perm" == "w" -o "$world_w_perm" == "w" ]; then echo $perms - echo "helper scripts must not be group or world writable! Dying on file $file" - exit + echo "helper scripts must not be group or world writable! Dying on file $file" + exit fi if [ `ls -ld $file | awk '{print $3}'` != "root" ]; then echo "helper scripts must be owned by root! Dying on file $file" @@ -87,6 +88,25 @@ do_run() { read } +do_xedit() { + if [ -z "$EDITOR" -o ! -x "`which $EDITOR`" ]; then + if [ -h /etc/alternatives/editor -a -x "`readlink /etc/alternatives/editor`" ]; then + EDITOR="`readlink /etc/alternatives/editor`" + elif [ -x "`which nano`" ]; then + EDITOR="`which nano`" + elif [ -x "`which vim`" ]; then + EDITOR="`which vim`" + elif [ -x "`which vi`" ]; then + EDITOR="`which vi`" + else + echo "No suitable editor found." + echo "Please define $EDITOR or configure /etc/alternatives/editor." + exit + fi + fi + $EDITOR $1 +} + do_run_test() { backupninja --test --run $1 echo "Hit return to continue..." @@ -130,7 +150,7 @@ doaction() { result="$REPLY" case "$result" in "view") dialog --textbox $action 0 0;; - "xedit") $EDITOR $action;; + "xedit") do_xedit $action;; "disable") do_disable $action; return;; "enable") do_enable $action; return;; "name") do_rename $action; return;; |