From 530b0509642fca674a72a0cb1422a0375c360723 Mon Sep 17 00:00:00 2001 From: risca Date: Mon, 8 Dec 2014 01:05:51 +0100 Subject: [PATCH 1/7] Now the path is absolute, therefore the install.sh script could be launched by any path, eg. the following will work as well: /bin/bash/ /home/myuser/PirateBoxScripts_Webserver-master/piratebox/install.sh Also line 36 and line 47 where pointing to incompatible launching path (the first was in PirateBoxScripts_Webserver-master/piratebox, the second just in PirateBoxScripts_Webserver-master/). --- piratebox/install.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/piratebox/install.sh b/piratebox/install.sh index 5cc6936..c3f9ea5 100755 --- a/piratebox/install.sh +++ b/piratebox/install.sh @@ -18,6 +18,7 @@ #======================================================================= #Import PirateBox conf CURRENT_CONF=piratebox/conf/piratebox.conf +CURRENT_DIR="$(dirname ${scriptfile})" #Must be root if [[ $EUID -ne 0 ]]; then @@ -32,7 +33,7 @@ else exit 0 fi -if [[ -f $CURRENT_CONF ]]; then +if [[ -f "$CURRENT_DIR"/$CURRENT_CONF ]]; then . $CURRENT_CONF 2> /dev/null else echo "PirateBox config is not in its normal directory" @@ -44,7 +45,7 @@ if [[ ! -d /opt ]]; then mkdir -p /opt fi -cp -rv piratebox/piratebox /opt &> /dev/null +cp -rv "$CURRENT_DIR"/piratebox /opt &> /dev/null echo "Finished copying files..." echo "$NET.$IP_SHORT piratebox.lan">>/etc/hosts echo "$NET.$IP_SHORT piratebox">>/etc/hosts From 3ae5c4d016c18031b73879a34b555611ce9a25f9 Mon Sep 17 00:00:00 2001 From: risca Date: Mon, 8 Dec 2014 01:15:49 +0100 Subject: [PATCH 2/7] Now the file path of the install.sh script is absolute, therefore it will be possible to launch the script also from other path like: /bin/bash /home/myuser/PirateBoxScripts_Webserver-master/piratebox/install.sh This also corrects a wrong path on line 47 that was causing the install script to fail. --- piratebox/install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/piratebox/install.sh b/piratebox/install.sh index c3f9ea5..4147439 100755 --- a/piratebox/install.sh +++ b/piratebox/install.sh @@ -18,6 +18,7 @@ #======================================================================= #Import PirateBox conf CURRENT_CONF=piratebox/conf/piratebox.conf +scriptfile="$(readlink -f $0)" CURRENT_DIR="$(dirname ${scriptfile})" #Must be root From 8fe529c58c1ae51a725356db86e1c9a412c6d6be Mon Sep 17 00:00:00 2001 From: risca Date: Mon, 8 Dec 2014 01:54:10 +0100 Subject: [PATCH 3/7] typo error: the default parameter of line 31 (src_file) should be a string, not a variable! --- piratebox/piratebox/bin/distribute_files.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/piratebox/piratebox/bin/distribute_files.sh b/piratebox/piratebox/bin/distribute_files.sh index 20530e5..4b56de0 100755 --- a/piratebox/piratebox/bin/distribute_files.sh +++ b/piratebox/piratebox/bin/distribute_files.sh @@ -28,7 +28,7 @@ destination=$1 overwrite=$2 overwrite=${overwrite:=false} src_file=$3 -src_file=${src_file:=all} +src_file=${src_file:="all"} $DEBUG && echo "parameters: destination $destination From 6d534fda7fe7d8ca554eb0573de04ceb4a2fbd5b Mon Sep 17 00:00:00 2001 From: risca Date: Mon, 8 Dec 2014 02:09:45 +0100 Subject: [PATCH 4/7] Dash compatibility issue (many system use dash as default shell) --- piratebox/piratebox/bin/install_piratebox.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/piratebox/piratebox/bin/install_piratebox.sh b/piratebox/piratebox/bin/install_piratebox.sh index 62fd102..bee7a87 100755 --- a/piratebox/piratebox/bin/install_piratebox.sh +++ b/piratebox/piratebox/bin/install_piratebox.sh @@ -76,8 +76,8 @@ if [ $2 = 'part2' ] ; then cp $PIRATEBOX_FOLDER/src/kareha.pl $PIRATEBOX_FOLDER/share/board fi - [[ ! -L $PIRATEBOX_FOLDER/www/board ]] && ln -s $PIRATEBOX_FOLDER/share/board $PIRATEBOX_FOLDER/www/board - [[ ! -L $PIRATEBOX_FOLDER/www/Shared ]] && ln -s $UPLOADFOLDER $PIRATEBOX_FOLDER/www/Shared + [ ! -L $PIRATEBOX_FOLDER/www/board ] && ln -s $PIRATEBOX_FOLDER/share/board $PIRATEBOX_FOLDER/www/board + [ ! -L $PIRATEBOX_FOLDER/www/Shared ] && ln -s $UPLOADFOLDER $PIRATEBOX_FOLDER/www/Shared fi #Install the image-board From 00646cbf960cc48d52e3f88b9a0eeb63bcbe929d Mon Sep 17 00:00:00 2001 From: risca Date: Mon, 8 Dec 2014 02:19:53 +0100 Subject: [PATCH 5/7] typo error: the comparison of string in bash require only on "=" --- piratebox/piratebox/bin/distribute_files.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/piratebox/piratebox/bin/distribute_files.sh b/piratebox/piratebox/bin/distribute_files.sh index 4b56de0..45d59c4 100755 --- a/piratebox/piratebox/bin/distribute_files.sh +++ b/piratebox/piratebox/bin/distribute_files.sh @@ -38,7 +38,7 @@ $DEBUG && echo "parameters: call script: $script "; -if [ "$src_file" == "all" ] ; then +if [ "$src_file" = "all" ] ; then work_on_file $destination $PIRATEBOX_FOLDER/src/HEADER.txt work_on_file $destination $PIRATEBOX_FOLDER/src/README.txt else From a8dcaf7f6bdc358396ac53c21ffd846674d662da Mon Sep 17 00:00:00 2001 From: risca Date: Mon, 8 Dec 2014 02:36:24 +0100 Subject: [PATCH 6/7] typo in bash test --- piratebox/piratebox/bin/distribute_file_into_directory.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/piratebox/piratebox/bin/distribute_file_into_directory.sh b/piratebox/piratebox/bin/distribute_file_into_directory.sh index 746b648..c051873 100755 --- a/piratebox/piratebox/bin/distribute_file_into_directory.sh +++ b/piratebox/piratebox/bin/distribute_file_into_directory.sh @@ -18,7 +18,7 @@ filename="${src_file##*/}" $DEBUG && echo "filename: $filename" $DEBUG && echo "Overwrite mode : $overwrite " -if [ ! -e $directory/$filename ] || [ "$overwrite" == "true" ] ; then +if [ ! -e $directory/$filename ] || [ "$overwrite" = true ] ; then echo "Distribute $filename into $directory " $DEBUG && echo " cp $src_file $directory " $TEST_RUN || cp $src_file $directory From 46b6500ff65d262cf37526db54c0306a8d56fd75 Mon Sep 17 00:00:00 2001 From: risca Date: Mon, 8 Dec 2014 02:38:34 +0100 Subject: [PATCH 7/7] typo in bash test --- piratebox/piratebox/init.d/piratebox | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/piratebox/piratebox/init.d/piratebox b/piratebox/piratebox/init.d/piratebox index f35aeae..d44e3e2 100755 --- a/piratebox/piratebox/init.d/piratebox +++ b/piratebox/piratebox/init.d/piratebox @@ -54,7 +54,7 @@ else fi -if [[ -f $PIRATEBOX/conf/init_done ]] ; then +if [ -f $PIRATEBOX/conf/init_done ] ; then INIT=OK else $PIRATEBOX/bin/hooks/hook_pre_init.sh "$CONF"