From 42fb1124f4535886440d3639f49ec0652fdbde95 Mon Sep 17 00:00:00 2001 From: Kristiyan Tsaklev Date: Thu, 11 Jan 2018 12:15:43 +0200 Subject: [PATCH 1/3] Look for the files in the dir of the script --- sdcard/debug_cmd.sh | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/sdcard/debug_cmd.sh b/sdcard/debug_cmd.sh index 4d00988..6b78526 100644 --- a/sdcard/debug_cmd.sh +++ b/sdcard/debug_cmd.sh @@ -1,30 +1,32 @@ #!/bin/sh # -cp /mnt/group /etc/group +DIR="$(dirname "$0")" + +cp "$DIR"/group /etc/group # install updated version of busybox cp /bin/busybox /bin/busybox-orig -cp /mnt/busybox-armv6l /bin/busybox +cp "$DIR"/busybox-armv6l /bin/busybox /bin/busybox --install -s # setup and install dropbear ssh server -cp /mnt/dropbearmulti /bin/dropbearmulti +cp "$DIR"/dropbearmulti /bin/dropbearmulti mkdir /etc/dropbear -cp /mnt/dropbear_ecdsa_host_key /etc/dropbear/dropbear_ecdsa_host_key +cp "$DIR"/dropbear_ecdsa_host_key /etc/dropbear/dropbear_ecdsa_host_key /bin/dropbearmulti dropbear # update hosts file to prevent communication -cp /mnt/hosts.new /etc/hosts +cp "$DIR"/hosts.new /etc/hosts # update the time ntpd -q -p uk.pool.ntp.org # wifi creds - currently doesn't work -#cp /mnt/wpa_supplicant.conf /home/wpa_supplicant.conf +#cp "$DIR"/wpa_supplicant.conf /home/wpa_supplicant.conf # update wifi creds - currently doesn't work -#(sleep 20 && /mnt/mmc01/0/goke_p2pcam_param --wifissid=SSID --wifipass=WIFIPASSKEY ) & +#(sleep 20 && "$DIR"/goke_p2pcam_param --wifissid=SSID --wifipass=WIFIPASSKEY ) & # turn off high pitched noise -(sleep 20 && /mnt/mmc01/0/goke_volume -s 0 ) & +(sleep 20 && "$DIR"/goke_volume -s 0 ) & From 3cae056bb6909ca47f0507fe4c05991512f1f155 Mon Sep 17 00:00:00 2001 From: Kristiyan Tsaklev Date: Thu, 11 Jan 2018 12:57:47 +0200 Subject: [PATCH 2/3] Make persistent changes --- sdcard/debug_cmd.sh | 75 +++++++++++++++++++++++++++++---------------- 1 file changed, 48 insertions(+), 27 deletions(-) diff --git a/sdcard/debug_cmd.sh b/sdcard/debug_cmd.sh index 6b78526..4682769 100644 --- a/sdcard/debug_cmd.sh +++ b/sdcard/debug_cmd.sh @@ -3,30 +3,51 @@ DIR="$(dirname "$0")" -cp "$DIR"/group /etc/group - -# install updated version of busybox -cp /bin/busybox /bin/busybox-orig -cp "$DIR"/busybox-armv6l /bin/busybox -/bin/busybox --install -s - -# setup and install dropbear ssh server -cp "$DIR"/dropbearmulti /bin/dropbearmulti -mkdir /etc/dropbear -cp "$DIR"/dropbear_ecdsa_host_key /etc/dropbear/dropbear_ecdsa_host_key -/bin/dropbearmulti dropbear - -# update hosts file to prevent communication -cp "$DIR"/hosts.new /etc/hosts - -# update the time -ntpd -q -p uk.pool.ntp.org - -# wifi creds - currently doesn't work -#cp "$DIR"/wpa_supplicant.conf /home/wpa_supplicant.conf - -# update wifi creds - currently doesn't work -#(sleep 20 && "$DIR"/goke_p2pcam_param --wifissid=SSID --wifipass=WIFIPASSKEY ) & - -# turn off high pitched noise -(sleep 20 && "$DIR"/goke_volume -s 0 ) & +if [ $DIR = /home/sdcard ]; then + cp "$DIR"/group /etc/group + + # install updated version of busybox + cp /bin/busybox /bin/busybox-orig + cp "$DIR"/busybox-armv6l /bin/busybox + /bin/busybox --install -s + + # setup and install dropbear ssh server + cp "$DIR"/dropbearmulti /bin/dropbearmulti + mkdir /etc/dropbear + cp "$DIR"/dropbear_ecdsa_host_key /etc/dropbear/dropbear_ecdsa_host_key + /bin/dropbearmulti dropbear + + # update hosts file to prevent communication + cp "$DIR"/hosts.new /etc/hosts + + # update the time + ntpd -q -p uk.pool.ntp.org + + # wifi creds - currently doesn't work + #cp "$DIR"/wpa_supplicant.conf /home/wpa_supplicant.conf + + # update wifi creds - currently doesn't work + #(sleep 20 && "$DIR"/goke_p2pcam_param --wifissid=SSID --wifipass=WIFIPASSKEY ) & + + # turn off high pitched noise + (sleep 20 && "$DIR"/goke_volume -s 0 ) & +else + # make folder for storing files + # and backup original start.sh script + if [ ! -d /home/sdcard ]; then + mkdir /home/sdcard + cp /home/start.sh /home/sdcard/start_orig.sh + fi + + # copy files over + cp "$DIR"/* /home/sdcard/ + + # Patch start.sh script to look in /home/sdcard/ + sed '\;/mnt/debug_cmd\.sh$;a\ +elif [ -f "/home/sdcard/debug_cmd.sh" ]; then\ + /home/sdcard/debug_cmd.sh' \ + /home/sdcard/start_orig.sh > /home/start.sh + + # call us again from the new location + exec /home/sdcard/debug_cmd.sh +fi From bf8753270bc97945876c905dcdf89787a368afd2 Mon Sep 17 00:00:00 2001 From: Kristiyan Tsaklev Date: Thu, 11 Jan 2018 14:34:23 +0200 Subject: [PATCH 3/3] Work with the nicer version of sed (just in case) --- sdcard/debug_cmd.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdcard/debug_cmd.sh b/sdcard/debug_cmd.sh index 4682769..80b01e7 100644 --- a/sdcard/debug_cmd.sh +++ b/sdcard/debug_cmd.sh @@ -43,7 +43,7 @@ else cp "$DIR"/* /home/sdcard/ # Patch start.sh script to look in /home/sdcard/ - sed '\;/mnt/debug_cmd\.sh$;a\ + "$DIR"/busybox-armv6l sed '\;/mnt/debug_cmd\.sh$;a\ elif [ -f "/home/sdcard/debug_cmd.sh" ]; then\ /home/sdcard/debug_cmd.sh' \ /home/sdcard/start_orig.sh > /home/start.sh