Skip to content

Commit

Permalink
Added Syncthing
Browse files Browse the repository at this point in the history
Minor installation fixes
  • Loading branch information
stefaang committed Mar 11, 2019
1 parent fe8fa98 commit 0d2b56e
Show file tree
Hide file tree
Showing 14 changed files with 189 additions and 0 deletions.
19 changes: 19 additions & 0 deletions wdpk/syncthing/apkg.rc
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions wdpk/syncthing/before_apkg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

[ -f /tmp/debug_apkg ] && echo "APKG_DEBUG: $0 $@" >> /tmp/debug_apkg

# DO NOT REMOVE
27 changes: 27 additions & 0 deletions wdpk/syncthing/build.sh
Original file line number Diff line number Diff line change
@@ -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 .


13 changes: 13 additions & 0 deletions wdpk/syncthing/clean.sh
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions wdpk/syncthing/env
Original file line number Diff line number Diff line change
@@ -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
16 changes: 16 additions & 0 deletions wdpk/syncthing/init.sh
Original file line number Diff line number Diff line change
@@ -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}

47 changes: 47 additions & 0 deletions wdpk/syncthing/install.sh
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions wdpk/syncthing/preinst.sh
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions wdpk/syncthing/remove.sh
Original file line number Diff line number Diff line change
@@ -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}
16 changes: 16 additions & 0 deletions wdpk/syncthing/start.sh
Original file line number Diff line number Diff line change
@@ -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}"

10 changes: 10 additions & 0 deletions wdpk/syncthing/stop.sh
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions wdpk/syncthing/web/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php header("Location: http://{$_SERVER['SERVER_ADDR']}:8384"); ?>
Binary file added wdpk/syncthing/web/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added wdpk/syncthing/web/syncthing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0d2b56e

Please sign in to comment.