Skip to content

Commit

Permalink
Add wallabag spk and cross (#2824)
Browse files Browse the repository at this point in the history
  • Loading branch information
tolkonepiu authored and KaraokeStu committed Jul 21, 2017
1 parent 48795ab commit 59968a8
Show file tree
Hide file tree
Showing 12 changed files with 361 additions and 0 deletions.
24 changes: 24 additions & 0 deletions cross/wallabag/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
PKG_NAME = wallabag
PKG_VERS = 2.2.3
PKG_EXT = tar.gz
PKG_DIST_NAME = $(PKG_NAME)-release-$(PKG_VERS).$(PKG_EXT)
PKG_DIST_FILE = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT)
PKG_DIST_SITE = https://static.wallabag.org/releases
PKG_DIR = release-$(PKG_VERS)

DEPENDS =

HOMEPAGE = https://www.wallabag.org/
COMMENT = Wallabag is a self hostable application allowing you to save an offline copy of your favorite articles. Click, save, read it when you can. It extracts content so that you can read it when you have time.
LICENSE = MIT

CONFIGURE_TARGET = nop
COMPILE_TARGET = nop
INSTALL_TARGET = myInstall

include ../../mk/spksrc.cross-cc.mk

.PHONY: myInstall
myInstall:
mkdir -p $(STAGING_INSTALL_PREFIX)/share/wallabag
tar -cf - -C $(WORK_DIR)/$(PKG_DIR) . | tar -xf - -C $(STAGING_INSTALL_PREFIX)/share/wallabag
1 change: 1 addition & 0 deletions cross/wallabag/PLIST
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
shr:share/wallabag
3 changes: 3 additions & 0 deletions cross/wallabag/digests
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
wallabag-2.2.3.tar.gz SHA1 496e6c7d980c078e42d3bab7b0e978bd0af02b96
wallabag-2.2.3.tar.gz SHA256 13fe5cb7cfc741abee08312f0055e9549e60590daff2fac41be5266f7956d857
wallabag-2.2.3.tar.gz MD5 63f4cc85397fd6db3e0e3d5f3fa11e02
49 changes: 49 additions & 0 deletions spk/wallabag/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
SPK_NAME = wallabag
SPK_VERS = 2.2.3
SPK_REV = 1
SPK_ICON = src/wallabag.png
DSM_UI_DIR = app
BETA = 1

DEPENDS = cross/$(SPK_NAME)

MAINTAINER = tolkonepiu
DESCRIPTION = Wallabag is a self hostable application allowing you to save an offline copy of your favorite articles. Click, save, read it when you can. It extracts content so that you can read it when you have time.
ADMIN_URL = /wallabag/web/
RELOAD_UI = yes
STARTABLE = no
DISPLAY_NAME = Wallabag
CHANGELOG = "Initial release"

HOMEPAGE = https://www.wallabag.org/
LICENSE = MIT

WIZARDS_DIR = src/wizard/

INSTALLER_SCRIPT = src/installer.sh
SSS_SCRIPT = src/dsm-control.sh


INSTALL_DEP_SERVICES = apache-web mysql
START_DEP_SERVICES = apache-web mysql
INSTUNINST_RESTART_SERVICES = apache-web

INSTALL_PREFIX = /usr/local/$(SPK_NAME)

POST_STRIP_TARGET = wallabag_extra_install

# Pure PHP package, make sure ARCH is not defined
override ARCH=

include ../../mk/spksrc.spk.mk

.PHONY: wallabag_extra_install
wallabag_extra_install:
install -m 644 src/parameters.yml $(STAGING_DIR)/share/${SPK_NAME}/app/config/parameters.yml
install -m 755 -d $(STAGING_DIR)/app
install -m 644 src/app/config $(STAGING_DIR)/app/config
install -m 755 -d $(STAGING_DIR)/app/images
for size in 16 24 32 48 72; do \
convert $(SPK_ICON) -thumbnail $${size}x$${size} \
$(STAGING_DIR)/app/images/$(SPK_NAME)-$${size}.png ; \
done
Empty file added spk/wallabag/PLIST
Empty file.
15 changes: 15 additions & 0 deletions spk/wallabag/src/app/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
".url": {
"com.synocommunity.packages.wallabag": {
"title": "Wallabag",
"desc": "Wallabag is a self hostable application allowing you to save an offline copy of your favorite articles. Click, save, read it when you can. It extracts content so that you can read it when you have time.",
"icon": "images/wallabag-{0}.png",
"type": "url",
"protocol": "http",
"port": "80",
"url": "/wallabag/web",
"allUsers": true,
"grantPrivilege": "local"
}
}
}
24 changes: 24 additions & 0 deletions spk/wallabag/src/dsm-control.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh

# Package
PACKAGE="wallabag"
DNAME="Wallabag"


case $1 in
start)
exit 0
;;
stop)
exit 0
;;
status)
exit 0
;;
log)
exit 1
;;
*)
exit 1
;;
esac
136 changes: 136 additions & 0 deletions spk/wallabag/src/installer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
#!/bin/sh

# Package
PACKAGE="wallabag"
DNAME="Wallabag"
PACKAGE_NAME="com.synocommunity.packages.${PACKAGE}"

# Others
INSTALL_DIR="/usr/local/${PACKAGE}"
WEB_DIR="/var/services/web"
USER="$([ $(/bin/get_key_value /etc.defaults/VERSION buildnumber) -ge 4418 ] && echo -n http || echo -n nobody)"
TMP_DIR="${SYNOPKG_PKGDEST}/../../@tmp"
PHP="$([ $(/bin/get_key_value /etc.defaults/VERSION buildnumber) -ge 7135 ] && echo -n /usr/local/bin/php56 || echo -n /usr/bin/php)"
MYSQL="/usr/bin/mysql"
MYSQLDUMP="/usr/bin/mysqldump"
CFG_FILE="${WEB_DIR}/${PACKAGE}/app/config/parameters.yml"
MYSQL_USER="wallabag"
MYSQL_DATABASE="wallabag"


preinst ()
{
# Check database
if [ "${SYNOPKG_PKG_STATUS}" == "INSTALL" ]; then
if ! ${MYSQL} -u root -p"${wizard_mysql_password_root}" -e quit > /dev/null 2>&1; then
echo "Incorrect MySQL root password"
exit 1
fi
if ${MYSQL} -u root -p"${wizard_mysql_password_root}" mysql -e "SELECT User FROM user" | grep ^${MYSQL_USER}$ > /dev/null 2>&1; then
echo "MySQL user ${MYSQL_USER} already exists"
exit 1
fi
if ${MYSQL} -u root -p"${wizard_mysql_password_root}" -e "SHOW DATABASES" | grep ^${MYSQL_DATABASE}$ > /dev/null 2>&1; then
echo "MySQL database ${MYSQL_DATABASE} already exists"
exit 1
fi
fi
exit 0
}

postinst ()
{
# Link
ln -s ${SYNOPKG_PKGDEST} ${INSTALL_DIR}

# Install the web interface
cp -pR ${INSTALL_DIR}/share/${PACKAGE} ${WEB_DIR}

if [ "${SYNOPKG_PKG_STATUS}" == "INSTALL" ]; then
# create wallabag database and user
${MYSQL} -u root -p"${wizard_mysql_password_root}" -e "CREATE DATABASE ${MYSQL_DATABASE}; GRANT ALL PRIVILEGES ON ${MYSQL_DATABASE}.* TO '${MYSQL_USER}'@'localhost' IDENTIFIED BY '${wizard_mysql_database_password}';"

# render properties
sed -i -e "s|@database_password@|${wizard_mysql_database_password}|g" \
-e "s|@database_name@|${MYSQL_DATABASE}|g" \
-e "s|@wallabag_secret@|$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 30 | head -n 1)|g" \
${CFG_FILE}

# install wallabag
if ! ${PHP} ${WEB_DIR}/${PACKAGE}/bin/console wallabag:install --env=prod --reset -n -vvv > ${WEB_DIR}/${PACKAGE}/install.log 2>&1; then
echo "Failed to install wallabag. Please check the log: ${WEB_DIR}/${PACKAGE}/install.log"
exit 1
fi
fi

# permissions
chown -R ${USER} ${WEB_DIR}/${PACKAGE}

exit 0
}

preuninst ()
{
# Check database
if [ "${SYNOPKG_PKG_STATUS}" == "UNINSTALL" ] && ! ${MYSQL} -u root -p"${wizard_mysql_password_root}" -e quit > /dev/null 2>&1; then
echo "Incorrect MySQL root password"
exit 1
fi

# Check database export location
if [ "${SYNOPKG_PKG_STATUS}" == "UNINSTALL" -a -n "${wizard_dbexport_path}" ]; then
if [ -f "${wizard_dbexport_path}" -o -e "${wizard_dbexport_path}/${MYSQL_DATABASE}.sql" ]; then
echo "File ${wizard_dbexport_path}/${MYSQL_DATABASE}.sql already exists. Please remove or choose a different location"
exit 1
fi
fi

exit 0
}

postuninst ()
{
# Remove link
rm -f ${INSTALL_DIR}

# Export and remove database
if [ "${SYNOPKG_PKG_STATUS}" == "UNINSTALL" ]; then
if [ -n "${wizard_dbexport_path}" ]; then
mkdir -p ${wizard_dbexport_path}
${MYSQLDUMP} -u root -p"${wizard_mysql_password_root}" ${MYSQL_DATABASE} > ${wizard_dbexport_path}/${MYSQL_DATABASE}.sql
fi
${MYSQL} -u root -p"${wizard_mysql_password_root}" -e "DROP DATABASE ${MYSQL_DATABASE}; DROP USER '${MYSQL_USER}'@'localhost';"
fi

# Remove the web interface
rm -rf ${WEB_DIR}/${PACKAGE}

exit 0
}

preupgrade ()
{
rm -rf ${TMP_DIR}/${PACKAGE}
mkdir -p ${TMP_DIR}/${PACKAGE}
mv ${CFG_FILE} ${TMP_DIR}/${PACKAGE}/
mv ${WEB_DIR}/${PACKAGE}/data/db ${TMP_DIR}/${PACKAGE}/
exit 0
}

postupgrade ()
{
mv ${TMP_DIR}/${PACKAGE}/parameters.yml ${CFG_FILE}
mv ${TMP_DIR}/${PACKAGE}/db ${WEB_DIR}/${PACKAGE}/data/db

# migrate database
if ! ${PHP} ${WEB_DIR}/${PACKAGE}/bin/console doctrine:migrations:migrate --env=prod -n -vvv > ${WEB_DIR}/${PACKAGE}/migration.log 2>&1; then
echo "Unable to migrate database schema. Please check the log: ${WEB_DIR}/${PACKAGE}/migration.log"
exit 1
fi

# permissions after upgrade
chown -R ${USER} ${WEB_DIR}/${PACKAGE}

rm -rf ${TMP_DIR}/${PACKAGE}
exit 0
}
34 changes: 34 additions & 0 deletions spk/wallabag/src/parameters.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
parameters:
database_driver: pdo_mysql
database_host: 127.0.0.1
database_port: 3306
database_name: @database_name@
database_user: wallabag
database_password: @database_password@
database_path: null
database_table_prefix: wallabag_
database_socket: null
database_charset: utf8mb4
mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_user: null
mailer_password: null
locale: en
secret: @wallabag_secret@
twofactor_auth: false
twofactor_sender: no-reply@wallabag.org
fosuser_registration: true
fosuser_confirmation: false
from_email: no-reply@wallabag.org
rss_limit: 50
rabbitmq_host: localhost
rabbitmq_port: 5672
rabbitmq_user: guest
rabbitmq_password: guest
rabbitmq_prefetch_count: 10
redis_scheme: tcp
redis_host: localhost
redis_port: 6379
redis_path: null
redis_password: null
sites_credentials: { }
Binary file added spk/wallabag/src/wallabag.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions spk/wallabag/src/wizard/install_uifile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[
{
"step_title":"Wallabag database configuration",
"items":[
{
"type":"password",
"desc":"Enter your MySQL password.",
"subitems":[
{
"key":"wizard_mysql_password_root",
"desc":"Root password",
"validator":{
"allowBlank":false
}
}
]
},
{
"type":"password",
"desc":"A 'wallabag' MySQL user and database will be created. Please enter a password for the 'wallabag' user.",
"subitems":[
{
"key":"wizard_mysql_database_password",
"desc":"User password",
"validator":{
"allowBlank":false
}
}
]
}
]
}, {
"step_title": "First login",
"items": [{
"desc": "The default credentials for the web interface is wallabag:wallabag. Change it on 'User Management' page."
}]
}
]
37 changes: 37 additions & 0 deletions spk/wallabag/src/wizard/uninstall_uifile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[
{
"step_title":"Remove wallabag database",
"items":[
{
"desc":"Attention: The wallabag database will be removed during package uninstallation. All entries will be deleted."
},
{
"type":"password",
"desc":"Enter your MySQL password",
"subitems":[
{
"key":"wizard_mysql_password_root",
"desc":"Root password"
}
]
},
{
"type":"textfield",
"desc":"Optional: Provide directory for database export. Leave blank to skip export. The directory will be created if it does not exist",
"subitems":[
{
"key":"wizard_dbexport_path",
"desc":"Database export location",
"validator":{
"allowBlank":true,
"regex":{
"expr":"/^\\\/volume[0-9]+\\\//",
"errorText":"Path should begin with /volume?/ with ? the number of the volume"
}
}
}
]
}
]
}
]

0 comments on commit 59968a8

Please sign in to comment.