Skip to content

Commit

Permalink
Merge pull request #70 from WDCommunity/rclone
Browse files Browse the repository at this point in the history
Add rclone package
  • Loading branch information
stefaang authored Nov 28, 2020
2 parents 5436c4b + 293d881 commit 7642b16
Show file tree
Hide file tree
Showing 15 changed files with 267 additions and 27 deletions.
62 changes: 35 additions & 27 deletions .github/workflows/wdpk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand All @@ -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
Expand Down
20 changes: 20 additions & 0 deletions wdpk/rclone/LICENSE
Original file line number Diff line number Diff line change
@@ -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.

19 changes: 19 additions & 0 deletions wdpk/rclone/apkg.rc
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions wdpk/rclone/before_apkg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

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

28 changes: 28 additions & 0 deletions wdpk/rclone/build.sh
Original file line number Diff line number Diff line change
@@ -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 .


13 changes: 13 additions & 0 deletions wdpk/rclone/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

WEBPATH="/var/www/rclone"

# remove bin
rm -f /usr/bin/rclone

# remove lib

# remove web
rm -rf $WEBPATH
6 changes: 6 additions & 0 deletions wdpk/rclone/env
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

APKG_NAME=rclone
PORT=5574
RCLONE_USER=mycloud
RCLONE_PW=mycloud
17 changes: 17 additions & 0 deletions wdpk/rclone/init.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

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

50 changes: 50 additions & 0 deletions wdpk/rclone/install.sh
Original file line number Diff line number Diff line change
@@ -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

17 changes: 17 additions & 0 deletions wdpk/rclone/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

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
20 changes: 20 additions & 0 deletions wdpk/rclone/remove.sh
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions wdpk/rclone/start.sh
Original file line number Diff line number Diff line change
@@ -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/.*<ip>\(\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}
4 changes: 4 additions & 0 deletions wdpk/rclone/stop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

# stop daemon
pkill rclone
17 changes: 17 additions & 0 deletions wdpk/rclone/web/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Expires" content=""-1>
<script>
function go(){
var my_url = document.domain;
location.href = "http://" + my_url + ":5574";
}
</script>
</head>
<body onload="go();">
</body>
</html>

Binary file added wdpk/rclone/web/rclone.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 7642b16

Please sign in to comment.