Skip to content

Commit

Permalink
Add instructions and helper scripts to create SPK installation packag…
Browse files Browse the repository at this point in the history
…e for Synology.
  • Loading branch information
skarppi authored and Juho Kolehmainen committed May 20, 2017
1 parent fd0922d commit 4dfd4cf
Show file tree
Hide file tree
Showing 13 changed files with 178 additions and 4 deletions.
26 changes: 22 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# iCloud Photos Downloader
# iCloud Photo Station

* A command-line tool to download all your iCloud photos.
* Works on Mac, Linux, and Windows.
* Works on Mac, Linux, Windows, and Synology DSM.
* Run it multiple times to download any new photos.
* Store photos either locally or [Synology NAS running Photo Station](https://www.synology.com/en-global/dsm/6.1/packages/PhotoStation).

Expand All @@ -17,8 +17,8 @@
### Installation

# Clone the repo somewhere
git clone https://github.com/ndbroadbent/icloud_photos_downloader.git
cd icloud_photos_downloader
git clone https://github.com/skarppi/icloud_photo_station.git
cd icloud_photo_station

# Install dependencies
sudo pip install -r requirements.txt
Expand Down Expand Up @@ -87,6 +87,24 @@ This process can take around 5-10 minutes, so please wait a few minutes, then tr

(If you are still seeing this message after 30 minutes, then please open an issue on GitHub.)

### Synology DSM installation and synching photos to Photo Station

# Create a SPK installation package containing virtualenv, python scripts and all necessary dependencies.

cd spk
sh build.sh

Manually install resulting `icloud_photo_station-0.1.0.spk` in your DSM `Package Station`. Now you can set up `User-defined script` into `Task Scheduler` and set up scheduling and notification emails for script output.

source /volume1/@appstore/icloud_photo_station/env/bin/activate
python /volume1/@appstore/icloud_photo_station/app/download_photos.py \
--username '<YOUR ICLOUD USERNAME>' \
--password '<YOUR ICLOUD PASSWORD>' \
--download-videos \
--recent 1000 \
--photostation 'http://<YOUR PHOTOSTATION USERNAME>:<YOUR PHOTOSTATION PASSWORD>@localhost/photo/webapi/' root-album

If your iCloud account has two-factor authentication enabled, SSH to Synology box and run the script manually first time in order to input the verification code.

### Run once every 3 hours using Cron

Expand Down
2 changes: 2 additions & 0 deletions spk/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
_*
*.spk
14 changes: 14 additions & 0 deletions spk/INFO
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package="icloud_photo_station"
version="0.1.0"
description="Synchronize iCloud Photos to Photo Station"

maintainer="Juho Kolehmainen"
arch="noarch"
displayname="iCloud Photo Station"
firmware="6.1-7321"
support_url="https://github.com/skarppi/icloud_photo_station"

install_dep_packages="PhotoStation"

startable="no"
thirdparty="yes"
Binary file added spk/PACKAGE_ICON.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 spk/PACKAGE_ICON_256.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
73 changes: 73 additions & 0 deletions spk/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/bin/bash

PKG_DIR=_spk
TGZ_DIR=_tgz

PKG_UTIL='pkg_util.sh'

VIRTUALENV='virtualenv-15.1.0.tar.gz'

clean() {
rm -fr $PKG_DIR
rm -fr $TGZ_DIR

#rm _${PKG_UTIL}
#rm _${VIRTUALENV}
}

setup() {

# download a helper script for creating Synology packages
if [ ! -f _${PKG_UTIL} ]; then
wget -O _${PKG_UTIL} https://raw.githubusercontent.com/SynologyOpenSource/pkgscripts-ng/master/include/${PKG_UTIL}
fi
source _${PKG_UTIL}

# download virtualenv distribution to be included in our installation package
if [ ! -f _${VIRTUALENV} ]; then
wget -O _${VIRTUALENV} https://pypi.python.org/packages/d4/0c/9840c08189e030873387a73b90ada981885010dd9aea134d6de30cd24cb8/${VIRTUALENV}
fi

mkdir -p $PKG_DIR
mkdir -p $TGZ_DIR
}

create_package_tgz() {
# Install virtual env and all libraries
tar xvfz _${VIRTUALENV} -C $TGZ_DIR
pip wheel --wheel-dir=${TGZ_DIR}/wheelhouse -r ../requirements.txt

# Copy python app
mkdir -p ${TGZ_DIR}/app
cp -av ../*.py $TGZ_DIR/app

# ### create package.tgz $1: source_dir $2: dest_dir
pkg_make_package $TGZ_DIR "${PKG_DIR}"
}

create_spk() {
local scripts_dir=$PKG_DIR/scripts

### Copy package center scripts to PKG_DIR
mkdir -p $scripts_dir
cp -av scripts/* $scripts_dir

### Copy package icon
cp -av PACKAGE_ICON*.PNG $PKG_DIR

### Copy INFO file
cp -av INFO $PKG_DIR/INFO

### Create the final spk.
# pkg_make_spk <source path> <dest path> <spk file name>
# Please put the result spk into /image/packages
# spk name functions: pkg_get_spk_name pkg_get_spk_unified_name pkg_get_spk_family_name
pkg_make_spk ${PKG_DIR} . $(pkg_get_spk_family_name)
}

clean
setup
create_package_tgz
create_spk

clean
13 changes: 13 additions & 0 deletions spk/scripts/postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh

### This script will be executed when package installed and upgraded.
### Actions after package installed.
### ex. create database, create symbolic link...

# Create a Python virtualenv
python ${SYNOPKG_PKGDEST}/virtualenv-15.1.0/virtualenv.py ${SYNOPKG_PKGDEST}/env

# Install the wheels
${SYNOPKG_PKGDEST}/env/bin/pip install --no-deps --no-index -U --force-reinstall -f ${SYNOPKG_PKGDEST}/wheelhouse ${SYNOPKG_PKGDEST}/wheelhouse/*.whl

exit 0
7 changes: 7 additions & 0 deletions spk/scripts/postuninst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

### This script will be executed when package uninstalled and upgraded.
### Actions after package uninstalled.
### ex. remove garbage files.

exit 0
7 changes: 7 additions & 0 deletions spk/scripts/postupgrade
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

### This script will be executed ONLY at package upgraded.
### Actions after package upgraded.
### ex. restore user settings.

exit 0
7 changes: 7 additions & 0 deletions spk/scripts/preinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

### This script will be execute when package installed and upgraded.
### Actions before package installed.
### ex. check environment.

exit 0
7 changes: 7 additions & 0 deletions spk/scripts/preuninst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

### This script will be executed when package uninstalled and upgraded.
### Actions before package uninstalled
### ex. backup package data.

exit 0
7 changes: 7 additions & 0 deletions spk/scripts/preupgrade
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

### This script will execute ONLY when package upgraded.
### Actions before package upgraded.
### ex. backup user settings for package upgrade.

exit 0
19 changes: 19 additions & 0 deletions spk/scripts/start-stop-status
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh

case $1 in
start)
exit 0
;;
stop)
exit 0
;;
status)
exit 0
;;
killall)
;;
log)
exit 0
;;
esac

0 comments on commit 4dfd4cf

Please sign in to comment.