diff --git a/wdpk/syncthing/apkg.rc b/wdpk/syncthing/apkg.rc new file mode 100644 index 0000000..f4fb5be --- /dev/null +++ b/wdpk/syncthing/apkg.rc @@ -0,0 +1,19 @@ +Package: syncthing +Version: 1.1.0 +Packager: TFL +Email: +Homepage: https://www.syncthing.net +Description: Open Source Continuous File Synchronization +Icon: logo.png +AddonShowName: Syncthing +AddonIndexPage: index.php +AddonUsedPort: +InstDepend: +InstConflict: +StartDepend: +StartConflict: +CenterType: +UserControl: +MinFWVer: +MaxFWVer: +IndividualFlag: 0 diff --git a/wdpk/syncthing/before_apkg.sh b/wdpk/syncthing/before_apkg.sh new file mode 100755 index 0000000..f48b086 --- /dev/null +++ b/wdpk/syncthing/before_apkg.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +[ -f /tmp/debug_apkg ] && echo "APKG_DEBUG: $0 $@" >> /tmp/debug_apkg + +# DO NOT REMOVE diff --git a/wdpk/syncthing/build.sh b/wdpk/syncthing/build.sh new file mode 100755 index 0000000..9d7b731 --- /dev/null +++ b/wdpk/syncthing/build.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +APP_NAME="$(basename $(pwd))" +DATE="$(date +"%m%d%Y")" +CWD="$(pwd)" +VERSION="$(awk '/Version/{print $NF}' apkg.rc)" + +echo "Building ${APP_NAME} version ${VERSION}" + +MODELS="WDMyCloudDL4100 WDMyCloudDL2100 MyCloudPR4100 MyCloudPR2100" + +for model in $MODELS; do + ../../mksapkg -E -s -m $model > /dev/null +done + +echo "Move binaries" + +RELEASE_DIR="../../packages/${APP_NAME}" +mkdir -p "${RELEASE_DIR}" +find .. -maxdepth 1 -name "*.bin*" -exec rename 's#\('$DATE'\)##' {} \; +mv ../*.bin "${RELEASE_DIR}" + +echo "Bundle sources" +SRC_TAR="${RELEASE_DIR}/${APP_NAME}_src_${VERSION}.tar.gz" +tar -czf $SRC_TAR . + + diff --git a/wdpk/syncthing/clean.sh b/wdpk/syncthing/clean.sh new file mode 100755 index 0000000..2660e65 --- /dev/null +++ b/wdpk/syncthing/clean.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +[ -f /tmp/debug_apkg ] && echo "APKG_DEBUG: $0 $@" >> /tmp/debug_apkg + +APKG_PATH=$(readlink -f $1) +. ${APKG_PATH}/env + +WEBPATH="/var/www/${APKG_NAME}" + +# remove lib + +# remove web +rm -rf $WEBPATH diff --git a/wdpk/syncthing/env b/wdpk/syncthing/env new file mode 100644 index 0000000..a98956c --- /dev/null +++ b/wdpk/syncthing/env @@ -0,0 +1,5 @@ +APKG_NAME="syncthing" +BINARY="syncthing" + +WEBGUI_ADDR=$(grep -m1 Require /usr/local/apache2/conf/httpd.conf | awk '{print $NF}' | cut -d/ -f1) +PORT=8384 diff --git a/wdpk/syncthing/init.sh b/wdpk/syncthing/init.sh new file mode 100755 index 0000000..eb36ee9 --- /dev/null +++ b/wdpk/syncthing/init.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +[ -f /tmp/debug_apkg ] && echo "APKG_DEBUG: $0 $@" >> /tmp/debug_apkg + +APKG_PATH=$(readlink -f $1) +. ${APKG_PATH}/env + +LOG=/tmp/${APKG_NAME}.log + +echo "INIT linking files from path: ${APKG_PATH}" >> $LOG + +# create directory for the webpage TODO FIX ME +WEBDIR="/var/www/${APKG_NAME}/" +mkdir -p ${WEBDIR} +ln -sf ${APKG_PATH}/web/* ${WEBDIR} + diff --git a/wdpk/syncthing/install.sh b/wdpk/syncthing/install.sh new file mode 100755 index 0000000..9a10bbc --- /dev/null +++ b/wdpk/syncthing/install.sh @@ -0,0 +1,47 @@ +#!/bin/sh + +[ -f /tmp/debug_apkg ] && echo "APKG_DEBUG: $0 $@" >> /tmp/debug_apkg + +INSTALL_DIR=$(readlink -f $1) +. ${INSTALL_DIR}/env + +NAS_PROG=$(readlink -f $2) + +log=/tmp/debug_apkg + +APKG_PATH="${NAS_PROG}/${APKG_NAME}" + +# move package data +mv ${INSTALL_DIR} ${NAS_PROG} + +# setup secure downloads +if [ ! -e /etc/ssl/cert.pem ]; then + curl --remote-name --time-cond cacert.pem https://curl.haxx.se/ca/cacert.pem + mv cacert.pem /etc/ssl/cert.pem +fi + +PLATFORM=$(uname -m) +if [ "${PLATFORM}" = "x86_64" ]; then + PLATFORM="amd64" +else + PLATFORM="arm" +fi +VERSION="v1.1.0" + +MAINDIR="syncthing-linux-${PLATFORM}-${VERSION}" +PACKAGE="${MAINDIR}.tar.gz" +URL="https://github.com/syncthing/syncthing/releases/download/${VERSION}/${PACKAGE}" + +/usr/bin/wget ${URL} + +[[ ! $? -eq 0 ]] && exit 1 + +tar xf ${PACKAGE} -C ${APKG_PATH} + +[[ ! $? -eq 0 ]] && exit 2 + +rm ${PACKAGE} + +mv ${APKG_PATH}/${MAINDIR} ${APKG_PATH}/${APKG_NAME} + +# TODO: restore config diff --git a/wdpk/syncthing/preinst.sh b/wdpk/syncthing/preinst.sh new file mode 100755 index 0000000..4f5559c --- /dev/null +++ b/wdpk/syncthing/preinst.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +[ -f /tmp/debug_apkg ] && echo "APKG_DEBUG: $0 $@" >> /tmp/debug_apkg + +NAS_PROG="/shares/Volume_1/Nas_Prog" + +APKG_MODULE="medusa" +APKG_PATH="${NAS_PROG}/${APKG_MODULE}" +APKG_BACKUP_PATH="${NAS_PROG}/${APKG_MODULE}_backup" +APKG_CONFIG="${APKG_PATH}/settings.conf" + +# backup config files and user settings +if [ -f $APKG_CONFIG ] ; then + # copy config to /tmp + mkdir -p ${APKG_BACKUP_PATH} + mv -f ${APKG_CONFIG} ${APKG_BACKUP_PATH} +fi diff --git a/wdpk/syncthing/remove.sh b/wdpk/syncthing/remove.sh new file mode 100755 index 0000000..8df3714 --- /dev/null +++ b/wdpk/syncthing/remove.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +[ -f /tmp/debug_apkg ] && echo "APKG_DEBUG: $0 $@" >> /tmp/debug_apkg + +APKG_PATH=$(readlink -f $1) +. ${APKG_PATH}/env + +rm -rf ${APKG_PATH} + +# remove lib + +# remove web +rm -rf /var/www/${APKG_NAME} diff --git a/wdpk/syncthing/start.sh b/wdpk/syncthing/start.sh new file mode 100755 index 0000000..ba7a338 --- /dev/null +++ b/wdpk/syncthing/start.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +APKG_PATH=$1 +. ${APKG_PATH}/env + +ADDRESS=$(grep -m1 'Require ip' /usr/local/apache2/conf/httpd.conf | awk '{print $NF}' | cut -d/ -f1) + +# disable creation of default folder +export STNODEFAULTFOLDER=0 + +# keep all persistent data in the syncthing home dir +ST_HOME=${APKG_PATH}/var + +# start the binary +${APKG_PATH}/syncthing/syncthing -no-browser -home=${ST_HOME} -gui-address="http://${ADDRESS}:${PORT}" + diff --git a/wdpk/syncthing/stop.sh b/wdpk/syncthing/stop.sh new file mode 100755 index 0000000..7fab345 --- /dev/null +++ b/wdpk/syncthing/stop.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +# stop daemon +APKG_DIR=$(readlink -f $1) +. ${APKG_DIR}/env + +if pidof ${BINARY} > /dev/null ; then + echo "Stopping ${APKG_NAME}" + kill $(pidof ${BINARY}) +fi diff --git a/wdpk/syncthing/web/index.php b/wdpk/syncthing/web/index.php new file mode 100644 index 0000000..040c173 --- /dev/null +++ b/wdpk/syncthing/web/index.php @@ -0,0 +1 @@ + diff --git a/wdpk/syncthing/web/logo.png b/wdpk/syncthing/web/logo.png new file mode 100644 index 0000000..2d45fff Binary files /dev/null and b/wdpk/syncthing/web/logo.png differ