diff --git a/.github/workflows/wdpk.yml b/.github/workflows/wdpk.yml index d3f3b8f..0a2431f 100644 --- a/.github/workflows/wdpk.yml +++ b/.github/workflows/wdpk.yml @@ -24,36 +24,46 @@ jobs: container: image: wdpk/wdpk options: -v ${{github.workspace}}/packages:/github/workspace/packages - # Steps represent a sequence of tasks that will be executed as part of the job + + # define all the OS5 supporting platforms and a prettier name + strategy: + matrix: + include: + - model: EX4100 + platform: WDMyCloudEX4100 + - model: DL4100 + platform: WDMyCloudDL4100 + - model: EX2100 + platform: WDMyCloudEX2100 + - model: DL2100 + platform: WDMyCloudDL2100 + - model: MirrorG2 + platform: WDMyCloudMirror + - model: EX2Ultra + platform: MyCloudEX2Ultra + - model: PR4100 + platform: MyCloudPR4100 + - model: PR2100 + platform: MyCloudPR2100 + + # Steps represent a sequence of tasks that will be executed as part of the job steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v2 - name: Get package that was changed in the last commit id: diff - env: - use_act: ${{ secrets.USE_ACT }}" run: | - #if [ -z "${use_act}" ]; then - echo "not using act ${use_act}" - wget ${{ github.event.pull_request.diff_url }} -O pr.diff - pkg=$(grep "^\+\+\+ b/wdpk/" pr.diff | cut -d/ -f3 | uniq) - #else - # echo "$(git show)" - # pkg=$(git diff-tree --name-only --no-commit-id -r HEAD~1 | grep ^wdpk | cut -d/ -f2 | uniq || error=true) - #fi + wget ${{ github.event.pull_request.diff_url }} -O pr.diff + pkg=$(grep "^\+\+\+ b/wdpk/" pr.diff | cut -d/ -f3 | uniq) + + # concat packages into single line pkgs="" for p in $pkg; do pkgs="${pkgs}${p} " done echo "Packages: ${pkgs}" - if [ -z "${use_act}" ]; then - echo "not using act ${use_act}" - echo ::set-output name=pkg::"${pkgs}" - else - echo "using act ${use_act}" - echo "PACKAGE=${pkgs}" >> $GITHUB_ENV - fi + echo "PACKAGE=${pkgs}" >> $GITHUB_ENV # TODO: use matrix instead - name: Get platforms @@ -65,6 +75,9 @@ jobs: - name: Make APKG packages for selected platforms id: make_apkg + env: + PLATFORM: ${{ matrix.platform }} + MODEL: ${{ matrix.model }} run: | pkg=$(echo ${PACKAGE} | cut -d' ' -f1) echo ::set-output name=pkg::"$pkg" @@ -81,15 +94,10 @@ jobs: RELEASE_DIR="../../packages/${pkg}/OS5" mkdir -p "${RELEASE_DIR}" - echo PLF $PLATFORMS - $arr - $PACKAGE - for fullmodel in $PLATFORMS - do - model=${fullmodel%-*} - name=${fullmodel#*-} - echo "Build ${pkg} for ${platform}" - ../../mksapkg-OS5 -E -s -m $model > /dev/null - mv ../${platform}*.bin\(* ../${pkg}_${VERSION}_${name}.bin - done + echo "PLF ${PLATFORM} - $arr - ${PACKAGE}" + echo "Build ${pkg} for $MODEL" + ../../mksapkg-OS5 -E -s -m ${PLATFORM} > /dev/null + mv ../${PLATFORM}*.bin\(* ../${pkg}_${VERSION}_${MODEL}.bin echo "$(ls -l ..)" - name: Upload artifacts diff --git a/wdpk/rclone/LICENSE b/wdpk/rclone/LICENSE new file mode 100644 index 0000000..8c27c67 --- /dev/null +++ b/wdpk/rclone/LICENSE @@ -0,0 +1,20 @@ +Copyright (C) 2012 by Nick Craig-Wood http://www.craig-wood.com/nick/ + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + diff --git a/wdpk/rclone/apkg.rc b/wdpk/rclone/apkg.rc new file mode 100644 index 0000000..8a29222 --- /dev/null +++ b/wdpk/rclone/apkg.rc @@ -0,0 +1,19 @@ +Package: rclone +Version: 27.11.17 +Packager: TFL +Email: +Homepage: https://rclone.org +Description: Manage files on cloud storage, including S3, business - consumer file storage services and standard transfer protocols. +Icon: rclone.png +AddonShowName: Rclone +AddonIndexPage: index.html +AddonUsedPort: +InstDepend: +InstConflict: +StartDepend: +StartConflict: +CenterType: +UserControl: +MinFWVer: +MaxFWVer: +IndividualFlag: 0 diff --git a/wdpk/rclone/before_apkg.sh b/wdpk/rclone/before_apkg.sh new file mode 100755 index 0000000..b08115a --- /dev/null +++ b/wdpk/rclone/before_apkg.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +[ -f /tmp/debug_apkg ] && echo "APKG_DEBUG: $0 $@" >> /tmp/debug_apkg + diff --git a/wdpk/rclone/build.sh b/wdpk/rclone/build.sh new file mode 100755 index 0000000..477525a --- /dev/null +++ b/wdpk/rclone/build.sh @@ -0,0 +1,28 @@ +#!/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}" + +RELEASE_DIR="../../packages/${APP_NAME}/OS5" +mkdir -p "${RELEASE_DIR}" + +MODELS="WDMyCloudEX4100-EX4100 WDMyCloudDL4100-DL4100 WDMyCloudEX2100-EX2100 WDMyCloudDL2100-DL2100 + WDMyCloudMirror-MirrorG2 MyCloudEX2Ultra-EX2Ultra MyCloudPR4100-PR4100 MyCloudPR2100-PR2100" + +for fullmodel in $MODELS; do + model=${fullmodel%-*} + name=${fullmodel#*-} + echo "$model $name" + ../../mksapkg-OS5 -E -s -m $model > /dev/null + mv ../${model}*.bin* "${RELEASE_DIR}/${APP_NAME}_${VERSION}_${name}.bin" +done + +echo "Bundle sources" +SRC_TAR="${RELEASE_DIR}/${APP_NAME}_${VERSION}_src.tar.gz" +tar -czf $SRC_TAR . + + diff --git a/wdpk/rclone/clean.sh b/wdpk/rclone/clean.sh new file mode 100755 index 0000000..b9d1d03 --- /dev/null +++ b/wdpk/rclone/clean.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +[ -f /tmp/debug_apkg ] && echo "APKG_DEBUG: $0 $@" >> /tmp/debug_apkg + +WEBPATH="/var/www/rclone" + +# remove bin +rm -f /usr/bin/rclone + +# remove lib + +# remove web +rm -rf $WEBPATH diff --git a/wdpk/rclone/env b/wdpk/rclone/env new file mode 100644 index 0000000..14abf24 --- /dev/null +++ b/wdpk/rclone/env @@ -0,0 +1,6 @@ +#!/bin/bash + +APKG_NAME=rclone +PORT=5574 +RCLONE_USER=mycloud +RCLONE_PW=mycloud diff --git a/wdpk/rclone/init.sh b/wdpk/rclone/init.sh new file mode 100755 index 0000000..33e46fc --- /dev/null +++ b/wdpk/rclone/init.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +[ -f /tmp/debug_apkg ] && echo "APKG_DEBUG: $0 $@" >> /tmp/debug_apkg + +path=$1 +log=/tmp/rclone.log + +echo "INIT linking files from path: $path" >> $log + +# create link to binary +ln -sf $path/rclone-*-linux-*/rclone /usr/bin/rclone + +# create folder for the webpage +WEBPATH="/var/www/rclone/" +mkdir -p $WEBPATH +ln -sf $path/web/* $WEBPATH + diff --git a/wdpk/rclone/install.sh b/wdpk/rclone/install.sh new file mode 100755 index 0000000..5be446a --- /dev/null +++ b/wdpk/rclone/install.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +[ -f /tmp/debug_apkg] && echo "APKG_DEBUG: $0 $@" >> /tmp/debug_apkg + +path_src=$1 +path_dst=$2 + +log=/tmp/debug_apkg + +APKG_MODULE="rclone" +APKG_PATH="${path_dst}/${APKG_MODULE}" +APKG_CONFIG="${APKG_PATH}/env" +APKG_BACKUP_DIR="${path_dst}/${APKG_MODULE}_backup/" + +# install all package scripts to the proper location +mv $path_src $path_dst + +# setup secure http +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 + +cd $path_dst/rclone + +# download the latest rclone installer +if [ "$(uname -m)" = "x86_64" ]; then + PLF=amd64 +else + PLF=arm +fi + +curl -O https://downloads.rclone.org/rclone-current-linux-${PLF}.zip +unzip rclone-current-linux-${PLF}.zip +chmod +x rclone-*-linux-${PLF}/rclone + +# remove the installer +rm rclone-current-linux-${PLF}.zip + +# restore previous config +if [ -d "${APKG_BACKUP_DIR}" ] +then + echo "Restore backup for ${APKG_MODULE}" >> $log + cp ${APKG_BACKUP_DIR}/* ${APKG_PATH} + rm -rf ${APKG_BACKUP_DIR} +else + echo "No backup found for ${APKG_MODULE} in ${APKG_BACKUP_DIR}" +fi +echo "Addon ${APKG_MODULE} (install.sh) done" >> $log + diff --git a/wdpk/rclone/preinst.sh b/wdpk/rclone/preinst.sh new file mode 100755 index 0000000..e50b60e --- /dev/null +++ b/wdpk/rclone/preinst.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +[ -f /tmp/debug_apkg ] && echo "APKG_DEBUG: $0 $@" >> /tmp/debug_apkg + +APKG_PATH=$1 + +APKG_MODULE="rclone" +APKG_BACKUP_PATH=${APKG_PATH}/../${APKG_MODULE}_backup + + +# backup config files and user settings +if [ ! -d ${APKG_BACKUP_PATH} ] ; then + # move config to backup path + mkdir -p ${APKG_BACKUP_PATH} + mv ${APKG_PATH}/rclone.config ${APKG_BACKUP_PATH} + mv ${APKG_PATH}/env ${APKG_BACKUP_PATH} +fi diff --git a/wdpk/rclone/remove.sh b/wdpk/rclone/remove.sh new file mode 100755 index 0000000..83c7d8d --- /dev/null +++ b/wdpk/rclone/remove.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +[ -f /tmp/debug_apkg ] && echo "APKG_DEBUG: $0 $@" >> /tmp/debug_apkg + +path=$1 + +# create a backup of the config +APKG_CONFIG="${path}/nzbget.conf" +APKG_BACKUP_CONFIG="/mnt/HD/HD_a2/.systemfile/nzbget.conf" +cp ${APKG_CONFIG} ${APKG_BACKUP_CONFIG} + +rm -rf $path + +# remove bin +rm -f /usr/bin/nzbget + +# remove lib + +# remove web +rm -rf /var/www/nzbget diff --git a/wdpk/rclone/start.sh b/wdpk/rclone/start.sh new file mode 100755 index 0000000..d216db6 --- /dev/null +++ b/wdpk/rclone/start.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +cd $(dirname $0) +source ./env + +CONFIG=$(pwd)/rclone.config + +[ ! -f /usr/bin/rclone ] echo "rclone not found" >> /tmp/debug_apkg + +[ -f /tmp/debug_apkg ] echo "APKG_DEBUG: starting Rclone" >> /tmp/debug_apkg + + + +ADDRESS=$(sed -n '/ip/ {s/.*\(\S*\)<\/ip>/\1/p;q}' /etc/NAS_CFG/config.xml ) + +# TODO: get user and pw from file +rclone rcd --config ${CONFIG} --rc-web-gui --rc-addr ${ADDRESS}:${PORT:-5582} --rc-user ${RCLONE_USER:-mycloud} --rc-pass ${RCLONE_PW:-mycloud} diff --git a/wdpk/rclone/stop.sh b/wdpk/rclone/stop.sh new file mode 100755 index 0000000..5636f11 --- /dev/null +++ b/wdpk/rclone/stop.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# stop daemon +pkill rclone diff --git a/wdpk/rclone/web/index.html b/wdpk/rclone/web/index.html new file mode 100644 index 0000000..a812f6b --- /dev/null +++ b/wdpk/rclone/web/index.html @@ -0,0 +1,17 @@ + + + + + + + + + + + + diff --git a/wdpk/rclone/web/rclone.png b/wdpk/rclone/web/rclone.png new file mode 100644 index 0000000..70332c0 Binary files /dev/null and b/wdpk/rclone/web/rclone.png differ