From eb425cc087e626375f70cd0cd7f5702501706b61 Mon Sep 17 00:00:00 2001 From: Matthias Strubel Date: Fri, 5 Sep 2014 14:50:46 +0200 Subject: [PATCH 01/14] Added minidlna feature en- & disable --- files/bin/box_init_setup.sh | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/files/bin/box_init_setup.sh b/files/bin/box_init_setup.sh index 0b268a8..ba75b4f 100755 --- a/files/bin/box_init_setup.sh +++ b/files/bin/box_init_setup.sh @@ -11,6 +11,12 @@ TIMESAVE_SCRIPT="/opt/piratebox/bin/timesave.sh" FTP_CONFIG_SCRIPT="/opt/piratebox/bin/ftp_enable.sh" FTP_CONFIG_AVAILABLE="-e $FTP_CONFIG_SCRIPT" +MINIDLNA_INITD="/etc/init.d/minidlna" +MINIDLNA_AVILABLE="-e $MINIDLNA_INITD" +MINIDLNA_PIRATEBOX_OPENWRT_CONFIG="/opt/piratebox/src/openwrt.example.minidlna" +MINIDLNA_OPENWRT_CONFIG="/etc/config/minidlna" +MINIDLNA_STATUS="disabled" + mainmenu() { @@ -25,6 +31,17 @@ mainmenu() { else echo " - FTP configuration not available" fi + if [ $MINIDLNA_AVILABLE ] ; then + $MINIDLNA_INITD enabled && MINIDLNA_STATUS="enabled" + echo -n " 4 - minidlna " + if [ "$MINIDLNA_STATUS" = "enabled" ] ; then + echo " disable" + else + echo " enable" + fi + else + echo " - minidlna not available" + fi echo "" echo " Everything else causes an exit" echo " " @@ -34,6 +51,7 @@ mainmenu() { ("1") _set_password_ ;; ("2") _set_date_ ;; ("3") _start_ftp_config_ ;; + ("4") _switch_minidlna_ ;; (*) exit 0;; esac option="" @@ -89,5 +107,24 @@ _start_ftp_config_() { } +_switch_minidlna_() { + if [ "$MINIDLNA_STATUS" = "enabled" ] ; then + $MINIDLNA_INITD disabled + $MINIDLNA_INITD stop + echo "minidlna disabled and stopped" + return 0 + else + $MINIDLNA_INITD enabled + + + MINIDLNA_PIRATEBOX_OPENWRT_CONFIG="/opt/piratebox/src/openwrt.example.minidlna" + MINIDLNA_OPENWRT_CONFIG="/etc/config/minidlna" + cp $MINIDLNA_PIRATEBOX_OPENWRT_CONFIG $MINIDLNA_OPENWRT_CONFIG + $MINIDLNA_INITD start + + echo "minidlna configuration copied. minidlna started" + fi + +} mainmenu From 1c2861b3cb9a11238732e2637980e3f84e08d99d Mon Sep 17 00:00:00 2001 From: Matthias Strubel Date: Thu, 11 Sep 2014 21:03:03 +0200 Subject: [PATCH 02/14] fixed typo --- files/bin/box_init_setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/bin/box_init_setup.sh b/files/bin/box_init_setup.sh index ba75b4f..7472f38 100755 --- a/files/bin/box_init_setup.sh +++ b/files/bin/box_init_setup.sh @@ -114,7 +114,7 @@ _switch_minidlna_() { echo "minidlna disabled and stopped" return 0 else - $MINIDLNA_INITD enabled + $MINIDLNA_INITD enable MINIDLNA_PIRATEBOX_OPENWRT_CONFIG="/opt/piratebox/src/openwrt.example.minidlna" From a9f74628fdee1bcb2d028a0bad03945d5deb3887 Mon Sep 17 00:00:00 2001 From: Matthias Strubel Date: Fri, 12 Sep 2014 15:53:26 +0200 Subject: [PATCH 03/14] Implements stop file. Stop file /mnt/usb/stop.txt is used, for preventing an automatic installation. It will be removed after it was discovered. The detection of it is logged into the logfile. Closed #11 --- files/bin/box_installer_start.sh | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/files/bin/box_installer_start.sh b/files/bin/box_installer_start.sh index 389a875..c1fb0b8 100755 --- a/files/bin/box_installer_start.sh +++ b/files/bin/box_installer_start.sh @@ -7,6 +7,8 @@ auto_package=/mnt/usb/install/auto_package auto_package_done=/mnt/usb/install/auto_package_done logfile=/mnt/usb/install.log +stopfile=/mnt/usb/stop.txt + start_log(){ ##Central function for logging; ## only start logging if not already online @@ -22,16 +24,25 @@ finish_log(){ cat /var/log/messages >> $logfile } -if ! /etc/init.d/ext enabled ; then +if [ -e $stopfile ] ; then + start_log + logger "$0 : Stop file detected. Ending processing" + rm $stopfile 2>&1 | logger + logger "$0 : Stop file removed." + finish_log + exit 0 +fi + +if ! /etc/init.d/ext enabled ; then start_log - logger "Doing extendRoot initilization" + logger "$0 : Doing extendRoot initilization" /bin/box_installer.sh -e 2>&1 | logger RC=$? if [ "$RC" -gt "0" ] ; then - logger "An error occured - Stopping process here ; $RC" + logger "$0 : An error occured - Stopping process here ; $RC" finish_log exit $RC fi @@ -54,7 +65,7 @@ if [ -e /mnt/usb/install/auto_package ]; then #Count containing lines, and only shift first to "done" package_lines=`cat $auto_package | wc -l` if [ "$package_lines" -gt "1" ] ; then - logger "Multiple line auto_package found. Shifting 1st line to auto_package_done" + logger "$0 : Multiple line auto_package found. Shifting 1st line to auto_package_done" tail -n +2 $auto_package > /tmp/auto_install_new mv /tmp/auto_install_new $auto_package else @@ -62,7 +73,7 @@ if [ -e /mnt/usb/install/auto_package ]; then fi - logger "Initiating reboot after installation" + logger "$0 : Initiating reboot after installation" finish_log sync && reboot else From 7e5bc9b3a5eb5758ab253421b751612942d3c445 Mon Sep 17 00:00:00 2001 From: Matthias Strubel Date: Fri, 12 Sep 2014 16:45:08 +0200 Subject: [PATCH 04/14] First implementation of auto-flash. Place the fitting image file to /auto_flash Fixes #12 --- files/bin/box_installer_start.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/files/bin/box_installer_start.sh b/files/bin/box_installer_start.sh index 389a875..2d9c216 100755 --- a/files/bin/box_installer_start.sh +++ b/files/bin/box_installer_start.sh @@ -7,6 +7,8 @@ auto_package=/mnt/usb/install/auto_package auto_package_done=/mnt/usb/install/auto_package_done logfile=/mnt/usb/install.log +new_image_location=/mnt/usb/auto_flash + start_log(){ ##Central function for logging; ## only start logging if not already online @@ -22,6 +24,28 @@ finish_log(){ cat /var/log/messages >> $logfile } + +if [ ls -1 "${new_image_location}"/openwrt-*.bin >> /dev/null 2>&1 ] ; then + ## Found image(s) at the download location + + ### get system var uci get box-installer. + model_type="" + + found_images=$( ls ${new_image_location}/openwrt-*${model_type}*.bin | wc -w ) + + if [ "$found_images" -eq 1 ] ; then + cnt=$( ls $new_image_location/openwrt-${model_type}*.bin.* ) + image_path=$( ls -1 ${new_image_location}/openwrt-${model_type}*.bin ) + logger "$0 : Creating backup of image file" + mv -v $image_path "${$image_path}.${cnt}" | logger + sysupgrade -n "${$image_path}.${cnt}" 2>&1 | logger + else + logger "$0 : More than one image found fitting to: " + logger "$0 : modeltype: ${model_type} " + ls ${new_image_location}/openwrt-${model_type}*.bin | logger + fi +fi + if ! /etc/init.d/ext enabled ; then start_log From 6e87605c278b6fd66a758eb1f76db6f500b91d8d Mon Sep 17 00:00:00 2001 From: Matthias Strubel Date: Tue, 23 Sep 2014 22:20:41 +0200 Subject: [PATCH 05/14] First working version of auto flash functionality. - place image file corresponding to the device to auto_flash folder on the USB Stick - Image check is done by sysupgrade - Check of supported arch. inside (ar71xx; all other will simply skip auto flash) - Perform a reboot - Logging not across syslogd anymore because it is about to be killed during flash Closes #12 --- files/bin/box_installer_start.sh | 43 ++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/files/bin/box_installer_start.sh b/files/bin/box_installer_start.sh index 2d9c216..a84d631 100755 --- a/files/bin/box_installer_start.sh +++ b/files/bin/box_installer_start.sh @@ -1,6 +1,5 @@ #!/bin/sh - PID=/var/run/auto_syslogd auto_package=/mnt/usb/install/auto_package @@ -24,26 +23,44 @@ finish_log(){ cat /var/log/messages >> $logfile } +auto_flash_supported(){ + ## Load OpenWRT release file + . /etc/openwrt_release + SUPPORTED_AUTOFLASH="ar71xx/generic" + + case "$DISTRIB_TARGET" in + "ar71xx/generic"*) \ + . /lib/ar71xx.sh + model_type=$( ar71xx_board_name ) + echo "$: Model Type ${model_type} identified" | logger + return 0 + ;; + esac || return 1 +} -if [ ls -1 "${new_image_location}"/openwrt-*.bin >> /dev/null 2>&1 ] ; then - ## Found image(s) at the download location - ### get system var uci get box-installer. - model_type="" +if auto_flash_supported && ls -1 "${new_image_location}"/openwrt-*.bin >> /dev/null 2>&1 ; then + ## Found image(s) at the download location found_images=$( ls ${new_image_location}/openwrt-*${model_type}*.bin | wc -w ) if [ "$found_images" -eq 1 ] ; then - cnt=$( ls $new_image_location/openwrt-${model_type}*.bin.* ) - image_path=$( ls -1 ${new_image_location}/openwrt-${model_type}*.bin ) - logger "$0 : Creating backup of image file" - mv -v $image_path "${$image_path}.${cnt}" | logger - sysupgrade -n "${$image_path}.${cnt}" 2>&1 | logger + cnt=$( ls $new_image_location/openwrt-*${model_type}*.bin* | wc -w ) + image_path=$( ls -1 ${new_image_location}/openwrt-*${model_type}*.bin ) + echo "$0 : Creating backup of image file - name: ${image_path}.${cnt} " + mv $image_path "${image_path}.${cnt}" + echo "$0: Copy image to /tmp " + filename=$(basename ${image_path} ) + cp "${image_path}.${cnt}" "/tmp/${filename}" + sysupgrade -n "/tmp/${filename}" 2>&1 + reboot && exit 0 else - logger "$0 : More than one image found fitting to: " - logger "$0 : modeltype: ${model_type} " - ls ${new_image_location}/openwrt-${model_type}*.bin | logger + echo "$0 : More than one image found fitting to: " + echo "$0 : modeltype: ${model_type} " + ls ${new_image_location}/openwrt-*${model_type}*.bin fi +else + auto_flash_supported || echo "$0 : unsupported architecture for auto flash- ${DISTRIB_TARGET}" fi if ! /etc/init.d/ext enabled ; then From 3b98fd6075265d38de2ee9256c0336a0244db355 Mon Sep 17 00:00:00 2001 From: Matthias Strubel Date: Thu, 16 Oct 2014 12:07:37 +0200 Subject: [PATCH 06/14] Version Number raize because of new autflash function --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d65aab6..4297af1 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ include $(TOPDIR)/rules.mk PKG_NAME:=box-installer -PKG_VERSION:=2.0.1 +PKG_VERSION:=2.1.1 PKG_RELEASE:=1 include $(INCLUDE_DIR)/package.mk From 9b3f123b06af49284dbf4f6c80dd1c41347bdcc3 Mon Sep 17 00:00:00 2001 From: Matthias Strubel Date: Thu, 16 Oct 2014 12:08:11 +0200 Subject: [PATCH 07/14] Revert "Version Number raize because of new autflash function" This reverts commit 3b98fd6075265d38de2ee9256c0336a0244db355. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 4297af1..d65aab6 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ include $(TOPDIR)/rules.mk PKG_NAME:=box-installer -PKG_VERSION:=2.1.1 +PKG_VERSION:=2.0.1 PKG_RELEASE:=1 include $(INCLUDE_DIR)/package.mk From 0c88eac2c7c010292d4ebf137b99e9b7a1b917eb Mon Sep 17 00:00:00 2001 From: Matthias Strubel Date: Thu, 16 Oct 2014 12:13:56 +0200 Subject: [PATCH 08/14] Version Raize because of the new features: - auto flash - stop file - several bug fixes --- Makefile | 2 +- README | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d65aab6..74ce132 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ include $(TOPDIR)/rules.mk PKG_NAME:=box-installer -PKG_VERSION:=2.0.1 +PKG_VERSION:=2.1.0 PKG_RELEASE:=1 include $(INCLUDE_DIR)/package.mk diff --git a/README b/README index 8409b06..113c353 100644 --- a/README +++ b/README @@ -37,6 +37,11 @@ Optional stuff: /stop.txt - If you create that file, the auto_package file won't be processed during one boot +/auto_flash - If you lay down an .bin file, that file will be flashed automatical + during the next boot, if it fits to the device. + That happens before auto_package is processed. + Flashed images will be renamed and flashed from the + ram (not directly from USB) What happens ------------- From c693c464123c1a948f582b969484e0c4ee23121a Mon Sep 17 00:00:00 2001 From: Matthias Strubel Date: Sat, 18 Apr 2015 12:21:38 +0200 Subject: [PATCH 09/14] Information update and version number Raize --- Makefile | 2 +- README | 44 ++++++++++++++++++++++++++++++++------------ 2 files changed, 33 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index d65aab6..74ce132 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ include $(TOPDIR)/rules.mk PKG_NAME:=box-installer -PKG_VERSION:=2.0.1 +PKG_VERSION:=2.1.0 PKG_RELEASE:=1 include $(INCLUDE_DIR)/package.mk diff --git a/README b/README index f1d59ef..4fdfbdb 100644 --- a/README +++ b/README @@ -24,23 +24,43 @@ Further Requirments. -------------------- On the USB Stick has to be located: -/installer - Contains - /auto_package - One lined file with the packages needed to be installed after bootup - /OpenWRT.img.gz - (prepared) ext3-image file - / - Stuff that needed by 'box packge - /cache - folder containing all needed .ipk files - /Package.gz_attitude_adjustment - Package-List from public repository - /Package.gz_piratebox - Package-List from PirateBox repository (optional) +/install - Contains + /auto_package - One or more lined file with the packages needed to be installed after bootup + /OpenWRT.img.gz - (prepared) ext3-image file + / - Stuff that needed by 'box packge + /cache - folder containing all needed .ipk files + /Package.gz_main - Package-List from public repository + /Package.gz_piratebox - Package-List from PirateBox repository (optional) +/auto_flash - Images in this folder will be used for flashing during bootup + After a reboot the .bin file is renamed. For flashing sysupgrade is used to + make a firmware compatibility check. + Befor reflashing, the file gets renamed, that it wont run into a loop, because + of incompatibilities. +/stop.txt - if that file is created, the auto installer will not start the auto installation. This is used + for manual interception during an upgrade or uncommon setups. +/install.log - Ongoing logfile written & appended during installation. + + What happens ------------- -During bootup, the box_installer_start.sh initiates the startup of the USB initialization, if extendRoot is not enabled at boot-time. -After extendRoot gets init, the script polls until a USB stick gets available. -On the further progress, it lookups on the install-folder for auto_package and installs that package(s) listed at the first line. -After everthing is done (valid or not), auto_package is renamed into auto_package_done (to prevent infinitive tries). -On a later start of the script, extendRoot does not get initialized anymore, so that would enable you to install additional packages later (maybe....). + +1. Check if the architecture is supported by auto flash tool and a image file is available. +1.1. If yes, try to identify the model. +1.2. If image foud, rename the image file with an incremented number (of existing files. That it won't be redetected again. +1.3. Create a copy into /tmp and execute sysupgrade on it. (and do a reboot) +2. If stop.txt exists, stop here. (create a log entry) +3. If extendRoot filesystem wasn't enabled, +3.1. start logging +3.2. Run box_installer script for extendRoot initialization. +3.3. Copy over logfile +4. If auto_package install file is there +4.1. run automatic package install +4.2. move installed packages out of auto_package to auto_package_done +4.3. if that was the last line, remove auto_package file +4.4. trigger a reboot Signaling on Router From 6bc5b89500924beac1e9ed7058d533f3f55ebb36 Mon Sep 17 00:00:00 2001 From: Matthias Strubel Date: Sun, 19 Apr 2015 17:37:54 +0200 Subject: [PATCH 10/14] Raizing version to 2.1.1 ; Fixes issue of self terminated sysupgrade --- Makefile | 2 +- files/bin/box_installer_start.sh | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 74ce132..4297af1 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ include $(TOPDIR)/rules.mk PKG_NAME:=box-installer -PKG_VERSION:=2.1.0 +PKG_VERSION:=2.1.1 PKG_RELEASE:=1 include $(INCLUDE_DIR)/package.mk diff --git a/files/bin/box_installer_start.sh b/files/bin/box_installer_start.sh index 289d24f..84da9af 100755 --- a/files/bin/box_installer_start.sh +++ b/files/bin/box_installer_start.sh @@ -53,8 +53,9 @@ if auto_flash_supported && ls -1 "${new_image_location}"/openwrt-*.bin >> /dev echo "$0: Copy image to /tmp " filename=$(basename ${image_path} ) cp "${image_path}.${cnt}" "/tmp/${filename}" - sysupgrade -n "/tmp/${filename}" 2>&1 - reboot && exit 0 + start-stop-daemon -b -S -x sysupgrade -- -n "/tmp/${filename}" 2>&1 + echo "Backgrounded sysupgrade, exiting now." + exit 0 else echo "$0 : More than one image found fitting to: " echo "$0 : modeltype: ${model_type} " From 90fdda40ac00bf1b7d6ec99f016de2420f89d062 Mon Sep 17 00:00:00 2001 From: Matthias Strubel Date: Sun, 19 Apr 2015 17:37:54 +0200 Subject: [PATCH 11/14] Raizing version to 2.1.1 ; Fixes issue of self terminated sysupgrade --- Makefile | 2 +- files/bin/box_installer_start.sh | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 74ce132..4297af1 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ include $(TOPDIR)/rules.mk PKG_NAME:=box-installer -PKG_VERSION:=2.1.0 +PKG_VERSION:=2.1.1 PKG_RELEASE:=1 include $(INCLUDE_DIR)/package.mk diff --git a/files/bin/box_installer_start.sh b/files/bin/box_installer_start.sh index 289d24f..84da9af 100755 --- a/files/bin/box_installer_start.sh +++ b/files/bin/box_installer_start.sh @@ -53,8 +53,9 @@ if auto_flash_supported && ls -1 "${new_image_location}"/openwrt-*.bin >> /dev echo "$0: Copy image to /tmp " filename=$(basename ${image_path} ) cp "${image_path}.${cnt}" "/tmp/${filename}" - sysupgrade -n "/tmp/${filename}" 2>&1 - reboot && exit 0 + start-stop-daemon -b -S -x sysupgrade -- -n "/tmp/${filename}" 2>&1 + echo "Backgrounded sysupgrade, exiting now." + exit 0 else echo "$0 : More than one image found fitting to: " echo "$0 : modeltype: ${model_type} " From c198b3bf04d67fb1a50bb02f3c02359bb40b288a Mon Sep 17 00:00:00 2001 From: Matthias Strubel Date: Tue, 18 Aug 2015 07:23:47 +0200 Subject: [PATCH 12/14] Fixs problem in disabling minidlna again. LibraryBox-Dev/LibraryBox-core#24 --- Makefile | 2 +- files/bin/box_init_setup.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 4297af1..73d60a5 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ include $(TOPDIR)/rules.mk PKG_NAME:=box-installer -PKG_VERSION:=2.1.1 +PKG_VERSION:=2.1.2 PKG_RELEASE:=1 include $(INCLUDE_DIR)/package.mk diff --git a/files/bin/box_init_setup.sh b/files/bin/box_init_setup.sh index 7472f38..21a3a37 100755 --- a/files/bin/box_init_setup.sh +++ b/files/bin/box_init_setup.sh @@ -109,7 +109,7 @@ _start_ftp_config_() { _switch_minidlna_() { if [ "$MINIDLNA_STATUS" = "enabled" ] ; then - $MINIDLNA_INITD disabled + $MINIDLNA_INITD disable $MINIDLNA_INITD stop echo "minidlna disabled and stopped" return 0 From 175355eb4cee694d064f917a2c4702cfc9ab9b21 Mon Sep 17 00:00:00 2001 From: Matthias Strubel Date: Thu, 10 Dec 2015 19:42:25 +0100 Subject: [PATCH 13/14] Version number raize --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 73d60a5..32fdfc0 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ include $(TOPDIR)/rules.mk PKG_NAME:=box-installer -PKG_VERSION:=2.1.2 +PKG_VERSION:=2.1.3 PKG_RELEASE:=1 include $(INCLUDE_DIR)/package.mk From ec0eda2ee5b97fc942a7923e1c78b1b0e0fab16a Mon Sep 17 00:00:00 2001 From: Matthias Strubel Date: Mon, 11 Apr 2016 17:58:21 +0200 Subject: [PATCH 14/14] Repository cleanup PirateBox-Dev/PirateBoxScripts_Webserver#139 --- Makefile | 74 ----------- README | 84 ------------ README.txt | 6 + files/bin/box_init_setup.sh | 130 ------------------ files/bin/box_installer.sh | 221 ------------------------------- files/bin/box_installer_start.sh | 124 ----------------- syslog_recv.py | 27 ---- 7 files changed, 6 insertions(+), 660 deletions(-) delete mode 100644 Makefile delete mode 100644 README create mode 100644 README.txt delete mode 100755 files/bin/box_init_setup.sh delete mode 100755 files/bin/box_installer.sh delete mode 100755 files/bin/box_installer_start.sh delete mode 100644 syslog_recv.py diff --git a/Makefile b/Makefile deleted file mode 100644 index 32fdfc0..0000000 --- a/Makefile +++ /dev/null @@ -1,74 +0,0 @@ -include $(TOPDIR)/rules.mk -PKG_NAME:=box-installer -PKG_VERSION:=2.1.3 -PKG_RELEASE:=1 - -include $(INCLUDE_DIR)/package.mk - -#----------- Defaults -define Package/box-installer/Default - SECTION:=utils - CATEGORY:=Utilities - TITLE:=box-installer Scripts - URL:=https://github.com/LibraryBox-Dev/LibraryBox-Installer/ - PKGARCH:=all - MAINTAINER:=Matthias Strubel -# SUBMENU:= -endef - -define Package/box-installer/Default/description - See https://github.com/LibraryBox-Dev/LibraryBox-Installer/ for more information. (Script is responsible for some kind of auto installation) -endef - - -define Package/box-installer/postinst/Default - #!/bin/sh - sed 's|^exit|#exit|' -i $$PKG_ROOT/etc/rc.local - echo '/bin/box_installer_start.sh' >> $$PKG_ROOT/etc/rc.local -endef - -define Package/box-installer/prerm/Default - #!/bin/sh - sed 's|/bin/box_installer_start.sh||' -i -i $$PKG_ROOT/etc/rc.local -endef - -define Package/box-installer/install/Default - $(INSTALL_DIR) $(1)/bin - $(INSTALL_BIN) ./files/bin/box_init_setup.sh $(1)/bin - $(INSTALL_BIN) ./files/bin/box_installer.sh $(1)/bin - $(INSTALL_BIN) ./files/bin/box_installer_start.sh $(1)/bin -endef - -define Build/Compile -endef - -define Build/Configure -endef - - -#---------- Base Package -define Package/box-installer - $(call Package/box-installer/Default) - DEPENDS:= +extendRoot -# MENU:=1 -endef - -define Package/box-installer/description - $(call Package/box-installer/Default/description) - This package comes without a package which should be installed. It contains only the installer itself -endef - -define Package/box-installer/postinst - $(call Package/box-installer/postinst/Default) -endef - -define Package/box-installer/prerm - $(call Package/box-installer/prerm/Default) -endef - -define Package/box-installer/install - $(call Package/box-installer/install/Default,$(1)) -endef - -#------------------ -$(eval $(call BuildPackage,box-installer)) diff --git a/README b/README deleted file mode 100644 index c8af4d6..0000000 --- a/README +++ /dev/null @@ -1,84 +0,0 @@ - -Installer script and helper stuff for an automatic installation of -LibraryBox on OpenWRT (with special custom image). - -Makefile - OpenWRT Makefile for box-installer package creation - - -syslog_recv.py - simply python script for client computer, - collecting installation log information. - Client has to be connected via wired and fixed - IP 192.168.1.2 - -files/bin/box_installer.sh - Script doing the work , loggs to STDOUT and STDERR -files/bin/box_installer_start.sh - Script launching syslog daemon and reroutes installer output to syslog-daeming. -files/bin/box_init_setup.sh - Script for a simple user menu setting time & password - -Requirements on the firmware: ------------------------------ - -Package "extendRoot" installed (not initialized) -Package "box-Installer" - -Further Requirments. --------------------- -On the USB Stick has to be located: - -/install - Contains - /auto_package - One or more lined file with the packages needed to be installed after bootup - /OpenWRT.img.gz - (prepared) ext3-image file - / - Stuff that needed by 'box packge - /cache - folder containing all needed .ipk files - /Package.gz_main - Package-List from public repository - /Package.gz_piratebox - Package-List from PirateBox repository (optional) -/auto_flash - Images in this folder will be used for flashing during bootup - After a reboot the .bin file is renamed. For flashing sysupgrade is used to - make a firmware compatibility check. - Befor reflashing, the file gets renamed, that it wont run into a loop, because - of incompatibilities. -/stop.txt - if that file is created, the auto installer will not start the auto installation. This is used - for manual interception during an upgrade or uncommon setups. -/install.log - Ongoing logfile written & appended during installation. - - - -Optional stuff: - -/stop.txt - If you create that file, the auto_package file won't be processed - during one boot - -/auto_flash - If you lay down an .bin file, that file will be flashed automatical - during the next boot, if it fits to the device. - That happens before auto_package is processed. - Flashed images will be renamed and flashed from the - ram (not directly from USB) - -What happens -------------- - - -1. Check if the architecture is supported by auto flash tool and a image file is available. -1.1. If yes, try to identify the model. -1.2. If image foud, rename the image file with an incremented number (of existing files. That it won't be redetected again. -1.3. Create a copy into /tmp and execute sysupgrade on it. (and do a reboot) -2. If stop.txt exists, stop here. (create a log entry) -3. If extendRoot filesystem wasn't enabled, -3.1. start logging -3.2. Run box_installer script for extendRoot initialization. -3.3. Copy over logfile -4. If auto_package install file is there -4.1. run automatic package install -4.2. move installed packages out of auto_package to auto_package_done -4.3. if that was the last line, remove auto_package file -4.4. trigger a reboot - - -Signaling on Router -------------------- - -If available and possible during the following steps, LED signals are given: - - 1. Start of extendRoot init ==>> Steady blinking wifi LED (can be all available WLAN-LEDs) - 2. END of extendRoot init ==>> Steady bright wifi LED - 3. Start of package installation ==> Steady blinking USB LED - 4. END of package installation ==> Steady brigh USB LED diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..dede37d --- /dev/null +++ b/README.txt @@ -0,0 +1,6 @@ + + + This repository is now maintained inside + https://github.com/PirateBox-Dev/openwrt-piratebox-feed + + 2016-04-05 ~ Matthias Strubel diff --git a/files/bin/box_init_setup.sh b/files/bin/box_init_setup.sh deleted file mode 100755 index 21a3a37..0000000 --- a/files/bin/box_init_setup.sh +++ /dev/null @@ -1,130 +0,0 @@ -#!/bin/sh - -### Initial Setup script for: -## - setting password -## - Date & Time with userinput -## => initialize timesave script if available. - -DEBUG=false -TIMESAVE_SCRIPT="/opt/piratebox/bin/timesave.sh" - -FTP_CONFIG_SCRIPT="/opt/piratebox/bin/ftp_enable.sh" -FTP_CONFIG_AVAILABLE="-e $FTP_CONFIG_SCRIPT" - -MINIDLNA_INITD="/etc/init.d/minidlna" -MINIDLNA_AVILABLE="-e $MINIDLNA_INITD" -MINIDLNA_PIRATEBOX_OPENWRT_CONFIG="/opt/piratebox/src/openwrt.example.minidlna" -MINIDLNA_OPENWRT_CONFIG="/etc/config/minidlna" -MINIDLNA_STATUS="disabled" - -mainmenu() { - - - while true - do - echo "-------------------------------------" - echo " " - echo " 1 - Setting password and enable SSH" - echo " 2 - Set date & time (enable timesave)" - if [ $FTP_CONFIG_AVAILABLE ] ; then - echo " 3 - Start FTP configuration " - else - echo " - FTP configuration not available" - fi - if [ $MINIDLNA_AVILABLE ] ; then - $MINIDLNA_INITD enabled && MINIDLNA_STATUS="enabled" - echo -n " 4 - minidlna " - if [ "$MINIDLNA_STATUS" = "enabled" ] ; then - echo " disable" - else - echo " enable" - fi - else - echo " - minidlna not available" - fi - echo "" - echo " Everything else causes an exit" - echo " " - read -p " Choose an option: " option - - case $option in - ("1") _set_password_ ;; - ("2") _set_date_ ;; - ("3") _start_ftp_config_ ;; - ("4") _switch_minidlna_ ;; - (*) exit 0;; - esac - option="" - done -} - -_set_password_() { - - echo "Please enter your password. The following command won't show you the entered letters." - local cmd=passwd - if [ "$DEBUG" = "false" ] ; then - $cmd && echo "$? ....OK" - else - echo "$cmd" - fi - -} - -_set_date_() { - - local year="" - local time_="" - - read -p "Please enter your date in the format YYYYMMDD : " year - read -p "Please enter your time in the format HHMM : " time_ - datetime="$year""$time_" - local cmd="date $datetime" - if [ $DEBUG = "false" ] ; then - $cmd && echo "... OK" - else - echo "$cmd" - fi - # If timesave script is available, and it is not already installed, install it. - if [ -e $TIMESAVE_SCRIPT ] ; then - if ! crontab -l | grep -q timesave.sh ; then - $TIMESAVE_SCRIPT /opt/piratebox/conf/piratebox.conf install - # Create OpenWRT cron-enabling and insert into rc.local - /etc/init.d/piratebox timesave - else - $TIMESAVE_SCRIPT /opt/piratebox/conf/piratebox.conf save - fi - fi -} - -_start_ftp_config_() { - - if [ $FTP_CONFIG_AVAILABLE ] ; then - . $FTP_CONFIG_SCRIPT - else - echo "FTP configuration not available" - fi - return 0 - -} - -_switch_minidlna_() { - if [ "$MINIDLNA_STATUS" = "enabled" ] ; then - $MINIDLNA_INITD disable - $MINIDLNA_INITD stop - echo "minidlna disabled and stopped" - return 0 - else - $MINIDLNA_INITD enable - - - MINIDLNA_PIRATEBOX_OPENWRT_CONFIG="/opt/piratebox/src/openwrt.example.minidlna" - MINIDLNA_OPENWRT_CONFIG="/etc/config/minidlna" - cp $MINIDLNA_PIRATEBOX_OPENWRT_CONFIG $MINIDLNA_OPENWRT_CONFIG - $MINIDLNA_INITD start - - echo "minidlna configuration copied. minidlna started" - fi - -} - -mainmenu diff --git a/files/bin/box_installer.sh b/files/bin/box_installer.sh deleted file mode 100755 index 34c94e1..0000000 --- a/files/bin/box_installer.sh +++ /dev/null @@ -1,221 +0,0 @@ -#!/bin/sh - -# Auto Install script for LibraryBox. -# Installs the one listed package from auto_package to ext-install - -INSTALL_PACKAGE_FILE=/mnt/usb/install/auto_package - -CACHE_LOCATION="/mnt/usb/install/cache" -INSTALL_DESTINATION="-d ext" - -OPKG="opkg --cache $CACHE_LOCATION " -OPKG_DEST="$OPKG $INSTALL_DESTINATION " - -NEXT_STEP="run_test" -ALL_STEPS="yes" -DO_PACKAGE="no" -DO_EXT="no" - - -LED_EXTENDROOT=/sys/class/leds/*wlan -LED_PACKAGE_1=/sys/class/leds/*3g -LED_PACKAGE_2=/sys/class/leds/*usb - - - -_signaling_start(){ - for file in $1 ; do echo "timer" > $file/trigger ; done - return 0 -} - -_signaling_stop(){ - for file in $1 ; do echo "none" > $file/trigger ; done - for file in $1 ; do echo "1" > $file/brightness ; done - return 0 -} - -calc_next_step() { - - case $NEXT_STEP in - - 'run_test') NEXT_STEP="run_signaling_extendRoot_start" ;; - 'run_signaling_extendRoot_start') NEXT_STEP="run_prepare_extendRoot" ;; - 'run_prepare_extendRoot') NEXT_STEP="run_init_extendRoot" ;; - 'run_init_extendRoot') NEXT_STEP="run_signaling_extendRoot_stop" ;; - - 'run_signaling_extendRoot_stop') - if [ "$DO_PACKAGE" = "yes" ] ; then - NEXT_STEP="run_test_installation_destination" - else - NEXT_STEP="exit" - fi ;; - 'run_test_installation_destination') NEXT_STEP='run_fake_opkg_update' ;; - 'run_fake_opkg_update') NEXT_STEP="run_signaling_package_start" ;; - 'run_signaling_package_start') NEXT_STEP="run_install_package" ;; - 'run_install_package') NEXT_STEP="run_signaling_package_stop" ;; - 'run_signaling_package_stop') NEXT_STEP="exit" ;; - *) echo "$0 : unknown previous step..exiting" - exit 255 ;; - esac -} - -run_test() { - #This section includes some tests to ensure everything is as we need it - echo "$0 : Testing requirements..." - if lsmod | grep -q usb_storage ; then - echo "$0 : .. USB storage modules available" - else - echo "$0 : No usb-storage storage modules detected..exit" - exit 255 - fi - if opkg list-installed extendRoot | grep -q extendRoot ; then - echo "$0 : extendRoot package is installed" - else - echo "$0 : extendRoot not available, exiting" - exit 255 - fi -} - - -run_signaling_extendRoot_start(){ - #Switch wlan-light online, that extendRoot init is running - _signaling_start "$LED_EXTENDROOT" - return 0 -} - -run_prepare_extendRoot(){ - #sets flags for installation of extendRoot to prevent the package asking the user - echo "$0 : configure initi step for extendRoot" - . /etc/ext.config - touch $ext_force_ext_overwrite - [ $? ] || exit $? -} - -run_init_extendRoot() { - if /etc/init.d/ext enabled ; then - echo "$0 : not running extendRoot init, because it already is" - return 0 - fi - /etc/init.d/ext init - [ $? ] || exit $? - -} - -# Signalize with a steady wifi light, that extendRoot initialization is done -run_signaling_extendRoot_stop(){ - _signaling_stop "$LED_EXTENDROOT" -} - -run_test_installation_destination(){ - echo "$0 : Testing if installation destination by extendRoot is available." - /etc/init.d/ext is_ready && OK="yes" - if [ "$OK" = "yes" ] ; then - echo "$0 : Installation destination is available." - else - echo "$0 : Something happend to extendRoot filesystem. Printing debug output..." - echo "$0 : Mount output" - mount - echo "$0 : dmesg | grep sd " - dmesg | grep sd - echo "$0 : dmesg | grep loop" - dmesg | grep loop - echo "$0 : dmesg | grep ext" - dmesg | grep ext - echo "$0 : Exiting box-installer routine" - exit 255 - fi -} - - -run_fake_opkg_update() { - echo "$0 : Creating opkg-lists folder, if missing" - mkdir -p /var/opkg-lists - echo "$0 : Getting main Repository from /etc/opkg.conf" - local repo=$(head -n1 /etc/opkg.conf | cut -d ' ' -f 2) - echo "$0 : Doing fake opkg update (copy from cache folder ($repo)" - cp $CACHE_LOCATION/Package.gz_main /var/opkg-lists/$repo - [ $? ] || exit $? - echo "$0 : .. doing it for Piratebox repository (optional)" - cp $CACHE_LOCATION/Package.gz_piratebox /var/opkg-lists/piratebox -} - -run_signaling_package_start(){ - #Blinking 3g/USB LED - _signaling_start "$LED_PACKAGE_1" - _signaling_start "$LED_PACKAGE_2" -} - -run_install_package(){ - # This can only happen if extendRoot is not initialized - # and the auto-install file is not on the USB Stick - if [ ! -e $INSTALL_PACKAGE_FILE ] ; then - echo "$0 : ERROR: $INSTALL_PACKAGE_FILE is not set" - exit 255 - fi - - echo "$0 : Fixing paths" - /bin/ext_path_fixer - - INSTALL_PACKAGE=`head -n 1 $INSTALL_PACKAGE_FILE` - echo "$0 : Installing packge $INSTALL_PACKAGE " - $OPKG_DEST install $INSTALL_PACKAGE - [ $? ] || exit $? -} - -run_signaling_package_stop(){ - #Blinking 3g/USB LED - _signaling_stop "$LED_PACKAGE_1" - _signaling_stop "$LED_PACKAGE_2" -} - - - -# Implement and option to process single steps -usage(){ -echo " Auto installer core script. - -Use the following parameter to trigger actions - -e : extendRoot init only - -p : install auto package file - -n : resume with step - -o : resume only named step - -one of -e or -p is required. -"; -exit 1 -} - -while getopts ":epon:" opt; do - case "${opt}" in - n) NEXT_STEP="${OPTARG}" ;; - p) DO_PACKAGE="yes" ;; - e) DO_EXT="yes" ;; - o) ALL_STEPS="no";; - ?) usage ;; - esac -done - -if [ "$DO_EXT" = "no" ] && [ "$DO_PACKAGE" = "no" ] ; then - usage -fi - -## Default parameter starts with extendRoot -## and ends after it init, when DO_PACKAGE=no - -if [ "$DO_EXT" = "no" ] && [ "$DO_PACKAGE" = "yes" ] ; then - NEXT_STEP="run_test_installation_destination" -fi - -while true; do - echo "$0 : executing $NEXT_STEP" - $NEXT_STEP - - if [ "$ALL_STEPS" = "yes" ] ; then - echo "$0 : Trying to find next step" - calc_next_step - else - echo "$0 : exiting because we run only one step" - exit $? - fi -done - diff --git a/files/bin/box_installer_start.sh b/files/bin/box_installer_start.sh deleted file mode 100755 index 84da9af..0000000 --- a/files/bin/box_installer_start.sh +++ /dev/null @@ -1,124 +0,0 @@ -#!/bin/sh - -PID=/var/run/auto_syslogd - -auto_package=/mnt/usb/install/auto_package -auto_package_done=/mnt/usb/install/auto_package_done -logfile=/mnt/usb/install.log - -new_image_location=/mnt/usb/auto_flash -stopfile=/mnt/usb/stop.txt - -start_log(){ -##Central function for logging; -## only start logging if not already online - if [ ! -e $PID ] ; then - [ -e $logfile ] && echo "---------------------------------------------" >> $logfile - start-stop-daemon -b -S -m -p $PID -x syslogd -- -n -L -R 192.168.1.2:9999 - fi -} - -finish_log(){ - ## Copy log to USB disc - echo "$0 : Logging install log to USB-Stick" - cat /var/log/messages >> $logfile -} - -auto_flash_supported(){ - ## Load OpenWRT release file - . /etc/openwrt_release - SUPPORTED_AUTOFLASH="ar71xx/generic" - - case "$DISTRIB_TARGET" in - "ar71xx/generic"*) \ - . /lib/ar71xx.sh - model_type=$( ar71xx_board_name ) - echo "$: Model Type ${model_type} identified" | logger - return 0 - ;; - esac || return 1 -} - - - -if auto_flash_supported && ls -1 "${new_image_location}"/openwrt-*.bin >> /dev/null 2>&1 ; then - ## Found image(s) at the download location - found_images=$( ls ${new_image_location}/openwrt-*${model_type}*.bin | wc -w ) - - if [ "$found_images" -eq 1 ] ; then - cnt=$( ls $new_image_location/openwrt-*${model_type}*.bin* | wc -w ) - image_path=$( ls -1 ${new_image_location}/openwrt-*${model_type}*.bin ) - echo "$0 : Creating backup of image file - name: ${image_path}.${cnt} " - mv $image_path "${image_path}.${cnt}" - echo "$0: Copy image to /tmp " - filename=$(basename ${image_path} ) - cp "${image_path}.${cnt}" "/tmp/${filename}" - start-stop-daemon -b -S -x sysupgrade -- -n "/tmp/${filename}" 2>&1 - echo "Backgrounded sysupgrade, exiting now." - exit 0 - else - echo "$0 : More than one image found fitting to: " - echo "$0 : modeltype: ${model_type} " - ls ${new_image_location}/openwrt-*${model_type}*.bin - fi -else - auto_flash_supported || echo "$0 : unsupported architecture for auto flash- ${DISTRIB_TARGET}" -fi - -if [ -e $stopfile ] ; then - start_log - logger "$0 : Stop file detected. Ending processing" - rm $stopfile 2>&1 | logger - logger "$0 : Stop file removed." - finish_log - exit 0 -fi - -if ! /etc/init.d/ext enabled ; then - start_log - - logger "$0 : Doing extendRoot initilization" - - /bin/box_installer.sh -e 2>&1 | logger - - RC=$? - if [ "$RC" -gt "0" ] ; then - logger "$0 : An error occured - Stopping process here ; $RC" - finish_log - exit $RC - fi - - finish_log -fi - - -# Initiates the log facility and starts the installation -if [ -e /mnt/usb/install/auto_package ]; then - - start_log - - /bin/box_installer.sh -p 2>&1 | logger - - - # Always move the first line only - head -n 1 $auto_package >> $auto_package_done - - #Count containing lines, and only shift first to "done" - package_lines=`cat $auto_package | wc -l` - if [ "$package_lines" -gt "1" ] ; then - logger "$0 : Multiple line auto_package found. Shifting 1st line to auto_package_done" - tail -n +2 $auto_package > /tmp/auto_install_new - mv /tmp/auto_install_new $auto_package - else - rm $auto_package - fi - - - logger "$0 : Initiating reboot after installation" - finish_log - sync && reboot -else - echo "Does not run because /mnt/usb/install/auto_package does not exists" -fi - - diff --git a/syslog_recv.py b/syslog_recv.py deleted file mode 100644 index 106801c..0000000 --- a/syslog_recv.py +++ /dev/null @@ -1,27 +0,0 @@ -# Server program -# UDP VERSION - - -from socket import * - -# Set the socket parameters -host = "0.0.0.0" -port = 9999 -buf = 1024 -addr = (host,port) - -# Create socket and bind to address -UDPSock = socket(AF_INET,SOCK_DGRAM) -UDPSock.bind(addr) - -# Receive messages -while 1: - data,addr = UDPSock.recvfrom(buf) - if not data: - print "Client has exited!" - break - else: - print "Received message ", data,"" - -# Close socket -UDPSock.close()