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{J6FX~qqR)k&O}Tdff9V9-
zxQXw2NgF5tAwjNPYYIB%e$m&@A2G!|_0;&Snx$gVq-ad^SGI$UH}!6B7syR`djcSn
zNdlq#E(sd=rAYm@vh52UuNhV6eQIbgw|dwT^L+)wyrG{r%<)9h4BpADpHRmEHwC0u
zhi^C8q+2}-SV$K_z_gJapdfc_h6A5CkL#>0Q-V!0gS$0owgvS`OFEV>3v~AM6R!Pq{zJKaPQHQpI%lp`K>q{gM269P&Oh
zzO#*PEn-S^?>msrjM8o^WNu?WOzO>O+K%^hczF02q{W@i{qY8Wg`y?;=1D;G6Y;U?lDu=gIVqdFV|{brA%PgSb0Zs*pdj
zeA1ax8y+R&1>GZ_oOS(11nW(F;g~S}`6`&m<3-ZHXp!J3U^^lJ;_M`?M0`S`^N2TS
zl{hjQE;Kyea3l94l2r&&j&l;y*C{U(=dd+ght=owi&?i#?6c2Gd`QZxRi>LF$!4{v
zc!I6*mAEL-a~$<+%n4OZp;ym~$k?T)nOGl%b>`^zL<}M&B7D~WXr)nKnbaLEamUq#
zPzk%dJUH@h24B*5(jb1lYGr@l85aq~LIi|6UQ!@_eQxWZ$)a*s<*3}dpbBb`K&u`k
zoCT?tGH(XGqUmTsi$&wv7{+t15If^2?|0sr?!w3JuJj1pLslAzHj1_1nf#RyBSsly
z!j_XsR~xwtUt{gj=|j2O{MB1Vu3&YN$0^j3dyec5{w(V!%Q#BxYlFuMI>eKg{7T0L
zZ;O~Y!`V!EtW=b&8UW*hPMyi;Ds;bez8?d$%WVk
zUy2(yCEv=+tT=N|DAiEp{a%BvZ|!<}=S6E-o-cm~>mAEsxk$nvWQEpt=e}J-qfsjm)
UE-)&$xd9C0IsX9d#{5|Pe`qLcKmY&$
literal 0
HcmV?d00001
diff --git a/hooks/post_user_create b/hooks/post_user_create
deleted file mode 100644
index 24ebf8c..0000000
--- a/hooks/post_user_create
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/bin/bash
-
-user=$1
-
-sudo mkdir -p /home/$user
-sudo setfacl -m g:#GROUP#:rwx /home/$user
diff --git a/manifest.json b/manifest.json
deleted file mode 100644
index 180f241..0000000
--- a/manifest.json
+++ /dev/null
@@ -1,66 +0,0 @@
-{
- "package_format": 1,
- "id": "owncloud",
- "name": "OwnCloud",
- "description": {
- "en": "Sync & share your files, pictures, music, contacts, calendars, and much more!",
- "fr": "Synchronisez et partagez vos fichiers, images, musiques, contacts, calendriers, et bien plus !"
- },
- "url": "https://owncloud.org",
- "license": "AGPL-3",
- "version": "9.0.5",
- "maintainer": {
- "name": "jerome",
- "email": "jerome@yunohost.org"
- },
- "multi_instance": "true",
- "services": [
- "nginx",
- "php5-fpm",
- "mysql"
- ],
- "requirements": {
- "yunohost": ">= 2.3.16"
- },
- "arguments": {
- "install" : [
- {
- "name": "domain",
- "type": "domain",
- "ask": {
- "en": "Choose a domain for ownCloud",
- "fr": "Choisissez un domaine pour ownCloud"
- },
- "example": "domain.org"
- },
- {
- "name": "path",
- "type": "path",
- "ask": {
- "en": "Choose a path for ownCloud",
- "fr": "Choisissez un chemin pour ownCloud"
- },
- "example": "/owncloud",
- "default": "/owncloud"
- },
- {
- "name": "admin",
- "type": "user",
- "ask": {
- "en": "Choose the ownCloud administrator (must be an existing YunoHost user)",
- "fr": "Choisissez l'administrateur d'ownCloud (doit être un utilisateur YunoHost déjà existant)"
- },
- "example": "homer"
- },
- {
- "name": "user_home",
- "type": "boolean",
- "ask": {
- "en": "Access the users home folder from ownCloud?",
- "fr": "Accéder au dossier personnel des utilisateurs depuis ownCloud ?"
- },
- "default": false
- }
- ]
- }
-}
diff --git a/manifest.toml b/manifest.toml
new file mode 100644
index 0000000..dbf45ec
--- /dev/null
+++ b/manifest.toml
@@ -0,0 +1,66 @@
+packaging_format = 2
+
+id = "owncloud"
+name = "ownCloud"
+description.en = "Explain in *a few (10~15) words* the purpose of the app or what it actually does (it is meant to give a rough idea to users browsing a catalog of 100+ apps)"
+description.fr = "Expliquez en *quelques* (10~15) mots l'utilité de l'app ou ce qu'elle fait (l'objectif est de donner une idée grossière pour des utilisateurs qui naviguent dans un catalogue de 100+ apps)"
+
+version = "4.0.1.~ynh1"
+
+maintainers = [""]
+
+[upstream]
+license = "Apache-2.0"
+website = "https://owncloud.com"
+demo = "https://demo.example.com"
+admindoc = "https://doc.owncloud.com/"
+code = "https://github.com/owncloud/ocis"
+
+[integration]
+yunohost = ">= 11.2"
+architectures = "all"
+multi_instance = true
+ldap = false
+sso = false
+disk = "50M"
+ram.build = "50M"
+ram.runtime = "50M"
+
+[install]
+ [install.domain]
+ type = "domain"
+
+ [install.init_main_permission]
+ type = "group"
+ default = "visitors"
+
+ [install.password]
+ help.en = "Use the help field to add an information for the admin about this question."
+ help.fr = "Utilisez le champ aide pour ajouter une information à l'intention de l'administrateur à propos de cette question."
+ type = "password"
+
+[resources]
+
+ [resources.sources.main]
+ amd64.url = "https://download.owncloud.com/ocis/ocis/stable/4.0.1/ocis-4.0.1-linux-amd64"
+ amd64.sha256 = "91f21d74099f5ae24ea4686913e8c916b20736c3f6dd64b5536957af5a5e31ae"
+ i386.url = "https://download.owncloud.com/ocis/ocis/stable/4.0.1/ocis-4.0.1-linux-386"
+ i386.sha256 = "68f876f2f094e1c2f0056a39910c0a94751b4138d211ffeae11b56e53ff37998"
+ arm64.url = "https://download.owncloud.com/ocis/ocis/stable/4.0.1/ocis-4.0.1-linux-arm64"
+ arm64.sha256 = "0003cb8d81c8468397229e917ffdd25476d1355eb1258b08e855473880398da9"
+ armhf.url = "https://download.owncloud.com/ocis/ocis/stable/4.0.1/ocis-4.0.1-linux-arm"
+ armhf.sha256 = "d6cd4c21356f0ebaaa8bfda0e2b3bd481402248af4647c901141f85febc16106"
+ in_subdir = false
+ rename = "owncloud"
+
+ [resources.ports]
+ main.default = 9200
+
+ [resources.system_user]
+
+ [resources.install_dir]
+
+ [resources.data_dir]
+
+ [resources.permissions]
+ main.url = "/"
diff --git a/patches/00-add-logout_url-conf.patch b/patches/00-add-logout_url-conf.patch
deleted file mode 100644
index 54388e2..0000000
--- a/patches/00-add-logout_url-conf.patch
+++ /dev/null
@@ -1,15 +0,0 @@
---- a/lib/base.php 2016-04-04 21:26:47.281448433 +0200
-+++ b/lib/base.php 2016-04-04 21:27:16.034283534 +0200
-@@ -920,8 +920,10 @@
- \OC::$server->getConfig()->deleteUserValue(OC_User::getUser(), 'login_token', $_COOKIE['oc_token']);
- }
- OC_User::logout();
-- // redirect to webroot and add slash if webroot is empty
-- header("Location: " . \OC::$server->getURLGenerator()->getAbsoluteURL('/'));
-+ // Use system config or redirect to webroot and add slash if webroot is empty
-+ $redirect_url = $systemConfig->getValue('logout_url',
-+ \OC::$server->getURLGenerator()->getAbsoluteURL('/'));
-+ header("Location: " . $redirect_url);
- } else {
- // Redirect to default application
- OC_Util::redirectToDefaultPage();
diff --git a/scripts/_common.sh b/scripts/_common.sh
index d1a5e4b..1e47ce7 100644
--- a/scripts/_common.sh
+++ b/scripts/_common.sh
@@ -1,82 +1,19 @@
-#
-# Common variables
-#
+#!/bin/bash
-APPNAME="owncloud"
+#=================================================
+# COMMON VARIABLES
+#=================================================
+# PHP APP SPECIFIC
+#=================================================
-# ownCloud version
-VERSION="9.0.5"
+#=================================================
+# PERSONAL HELPERS
+#=================================================
-# Package name for ownCloud dependencies
-DEPS_PKG_NAME="owncloud-deps"
+#=================================================
+# EXPERIMENTAL HELPERS
+#=================================================
-# Remote URL to fetch ownCloud tarball
-OWNCLOUD_SOURCE_URL="https://download.owncloud.org/community/owncloud-${VERSION}.tar.bz2"
-
-# Remote URL to fetch ownCloud tarball checksum
-OWNCLOUD_SOURCE_SHA256="c8c2c4f7a06208f006762740ca6bb6a4c4d8362fc8d226dcccb82b970993f7c5"
-
-# App package root directory should be the parent folder
-PKGDIR=$(cd ../; pwd)
-
-#
-# Common helpers
-#
-
-# Download and extract ownCloud sources to the given directory
-# usage: extract_owncloud DESTDIR [AS_USER]
-extract_owncloud() {
- local DESTDIR=$1
- local AS_USER=${2:-admin}
-
- # retrieve and extract Roundcube tarball
- oc_tarball="/tmp/owncloud.tar.bz2"
- rm -f "$oc_tarball"
- wget -q -O "$oc_tarball" "$OWNCLOUD_SOURCE_URL" \
- || ynh_die "Unable to download ownCloud tarball"
- echo "$OWNCLOUD_SOURCE_SHA256 $oc_tarball" | sha256sum -c >/dev/null \
- || ynh_die "Invalid checksum of downloaded tarball"
- exec_as "$AS_USER" tar xjf "$oc_tarball" -C "$DESTDIR" --strip-components 1 \
- || ynh_die "Unable to extract ownCloud tarball"
- rm -f "$oc_tarball"
-
- # apply patches
- (cd "$DESTDIR" \
- && for p in ${PKGDIR}/patches/*.patch; do \
- exec_as "$AS_USER" patch -p1 < $p; done) \
- || ynh_die "Unable to apply patches to ownCloud"
-}
-
-# Execute a command as another user
-# usage: exec_as USER COMMAND [ARG ...]
-exec_as() {
- local USER=$1
- shift 1
-
- if [[ $USER = $(whoami) ]]; then
- eval "$@"
- else
- # use sudo twice to be root and be allowed to use another user
- sudo sudo -u "$USER" "$@"
- fi
-}
-
-# Execute a command with occ as a given user from a given directory
-# usage: exec_occ WORKDIR AS_USER COMMAND [ARG ...]
-exec_occ() {
- local WORKDIR=$1
- local AS_USER=$2
- shift 2
-
- (cd "$WORKDIR" && exec_as "$AS_USER" \
- php occ --no-interaction --no-ansi "$@")
-}
-
-# Check if an URL is already handled
-# usage: is_url_handled URL
-is_url_handled() {
- local OUTPUT=($(curl -k -s -o /dev/null \
- -w 'x%{redirect_url} %{http_code}' "$1"))
- # it's handled if it does not redirect to the SSO nor return 404
- [[ ! ${OUTPUT[0]} =~ \/yunohost\/sso\/ && ${OUTPUT[1]} != 404 ]]
-}
+#=================================================
+# FUTURE OFFICIAL HELPERS
+#=================================================
diff --git a/scripts/backup b/scripts/backup
index 81606b8..cf2d1b6 100755
--- a/scripts/backup
+++ b/scripts/backup
@@ -1,39 +1,46 @@
#!/bin/bash
-set -eu
+#=================================================
+# GENERIC START
+#=================================================
+# IMPORT GENERIC HELPERS
+#=================================================
-# Get multi-instances specific variables
-app=$YNH_APP_INSTANCE_NAME
+# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
+source ../settings/scripts/_common.sh
+source /usr/share/yunohost/helpers
-# Set app specific variables
-dbname=$app
-dbuser=$app
+#=================================================
+# DECLARE DATA AND CONF FILES TO BACKUP
+#=================================================
+ynh_print_info --message="Declaring files to be backed up..."
-# Source app helpers
-. /usr/share/yunohost/helpers
+#=================================================
+# BACKUP THE APP MAIN DIR
+#=================================================
-# Retrieve app settings
-domain=$(ynh_app_setting_get "$app" domain)
-path=$(ynh_app_setting_get "$app" path)
-dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
+ynh_backup --src_path="$install_dir"
-# Copy the app source files
-DESTDIR="/var/www/$app"
-ynh_backup "$DESTDIR" "www"
+#=================================================
+# BACKUP THE DATA DIR
+#=================================================
-# Copy the data directory
-DATADIR="/home/yunohost.app/${app}/data"
-ynh_backup "$DATADIR" "data" 1
+ynh_backup --src_path="$data_dir" --is_big
-# Copy the conf files
-mkdir ./conf
-ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "conf/nginx.conf"
-ynh_backup "/etc/php5/fpm/pool.d/${app}.conf" "conf/php-fpm.conf"
-ynh_backup "/etc/cron.d/${app}" "conf/cron"
+#=================================================
+# BACKUP THE NGINX CONFIGURATION
+#=================================================
-# Dump the database
-mysqldump -u "$dbuser" -p"$dbpass" --no-create-db "$dbname" > ./db.sql
+ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
-# Copy the control file of the dependency package
-# FIXME: find a way to retrieve package name from _common.sh?
-dpkg-query -s owncloud-deps > ./owncloud-deps.control
+#=================================================
+# BACKUP SYSTEMD
+#=================================================
+
+ynh_backup --src_path="/etc/systemd/system/$app.service"
+
+#=================================================
+# END OF SCRIPT
+#=================================================
+
+ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
diff --git a/scripts/change_url b/scripts/change_url
new file mode 100644
index 0000000..ae914ad
--- /dev/null
+++ b/scripts/change_url
@@ -0,0 +1,41 @@
+#!/bin/bash
+
+#=================================================
+# GENERIC STARTING
+#=================================================
+# IMPORT GENERIC HELPERS
+#=================================================
+
+source _common.sh
+source /usr/share/yunohost/helpers
+
+#=================================================
+# STANDARD MODIFICATIONS
+#=================================================
+# STOP SYSTEMD SERVICE
+#=================================================
+ynh_script_progression --message="Stopping a systemd service..." --weight=1
+
+ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
+
+#=================================================
+# MODIFY URL IN NGINX CONF
+#=================================================
+ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
+
+ynh_change_url_nginx_config
+
+#=================================================
+# GENERIC FINALISATION
+#=================================================
+# START SYSTEMD SERVICE
+#=================================================
+ynh_script_progression --message="Starting a systemd service..." --weight=1
+
+ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
+
+#=================================================
+# END OF SCRIPT
+#=================================================
+
+ynh_script_progression --message="Change of URL completed for $app" --last
diff --git a/scripts/config b/scripts/config
new file mode 100644
index 0000000..b9e79f8
--- /dev/null
+++ b/scripts/config
@@ -0,0 +1,102 @@
+#!/bin/bash
+# In simple cases, you don't need a config script.
+
+# With a simple config_panel.toml, you can write in the app settings, in the
+# upstream config file or replace complete files (logo ...) and restart services.
+
+# The config scripts allows you to go further, to handle specific cases
+# (validation of several interdependent fields, specific getter/setter for a value,
+# display dynamic informations or choices, pre-loading of config type .cube... ).
+
+#=================================================
+# GENERIC STARTING
+#=================================================
+# IMPORT GENERIC HELPERS
+#=================================================
+
+source /usr/share/yunohost/helpers
+
+ynh_abort_if_errors
+
+#=================================================
+# RETRIEVE ARGUMENTS
+#=================================================
+
+final_path=$(ynh_app_setting_get $app final_path)
+
+#=================================================
+# SPECIFIC GETTERS FOR TOML SHORT KEY
+#=================================================
+
+get__amount() {
+ # Here we can imagine to have an API call to stripe to know the amount of donation during a month
+ local amount = 200
+
+ # It's possible to change some properties of the question by overriding it:
+ if [ $amount -gt 100 ]
+ then
+ cat << EOF
+style: success
+value: $amount
+ask:
+ en: A lot of donation this month: **$amount €**
+EOF
+ else
+ cat << EOF
+style: danger
+value: $amount
+ask:
+ en: Not so much donation this month: $amount €
+EOF
+ fi
+}
+
+get__prices() {
+ local prices = "$(grep "DONATION\['" "$final_path/settings.py" | sed -r "s@^DONATION\['([^']*)'\]\['([^']*)'\] = '([^']*)'@\1/\2/\3@g" | sed -z 's/\n/,/g;s/,$/\n/')"
+ if [ "$prices" == "," ];
+ then
+ # Return YNH_NULL if you prefer to not return a value at all.
+ echo YNH_NULL
+ else
+ echo $prices
+ fi
+}
+
+
+#=================================================
+# SPECIFIC VALIDATORS FOR TOML SHORT KEYS
+#=================================================
+validate__publishable_key() {
+
+ # We can imagine here we test if the key is really a publisheable key
+ (is_secret_key $publishable_key) &&
+ echo 'This key seems to be a secret key'
+}
+
+#=================================================
+# SPECIFIC SETTERS FOR TOML SHORT KEYS
+#=================================================
+set__prices() {
+
+ #---------------------------------------------
+ # IMPORTANT: setter are trigger only if a change is detected
+ #---------------------------------------------
+ for price in $(echo $prices | sed "s/,/ /"); do
+ frequency=$(echo $price | cut -d/ -f1)
+ currency=$(echo $price | cut -d/ -f2)
+ price_id=$(echo $price | cut -d/ -f3)
+ sed "d/DONATION\['$frequency'\]\['$currency'\]" "$final_path/settings.py"
+
+ echo "DONATION['$frequency']['$currency'] = '$price_id'" >> "$final_path/settings.py"
+ done
+
+ #---------------------------------------------
+ # IMPORTANT: to be able to upgrade properly, you have to saved the value in settings too
+ #---------------------------------------------
+ ynh_app_setting_set $app prices $prices
+}
+
+#=================================================
+# GENERIC FINALIZATION
+#=================================================
+ynh_app_config_run $1
diff --git a/scripts/install b/scripts/install
index 48c4b48..c4d47e0 100755
--- a/scripts/install
+++ b/scripts/install
@@ -1,178 +1,71 @@
#!/bin/bash
-set -eu
+#=================================================
+# GENERIC START
+#=================================================
+# IMPORT GENERIC HELPERS
+#=================================================
-# Get multi-instances specific variables
-app=$YNH_APP_INSTANCE_NAME
+source _common.sh
+source /usr/share/yunohost/helpers
-# Retrieve arguments
-domain=$1
-path=${2%/}
-admin=$3
-user_home=$4
+#=================================================
+# DOWNLOAD, CHECK AND UNPACK SOURCE
+#=================================================
+ynh_script_progression --message="Setting up source files..." --weight=1
-# Load common variables
-. ./_common.sh
+# Download, check integrity, uncompress and patch the source from app.src
+ynh_setup_source --dest_dir="$install_dir"
-# Set app specific variables
-dbname=$app
-dbuser=$app
+chmod 750 "$install_dir"
+chmod -R o-rwx "$install_dir"
+chown -R $app:www-data "$install_dir"
+chmod +x $install_dir/owncloud
-# Source app helpers
-. /usr/share/yunohost/helpers
+#=================================================
+# NGINX CONFIGURATION
+#=================================================
+ynh_script_progression --message="Configuring NGINX web server..." --weight=1
-# TODO: Check domain/path availability with app helper
-sudo yunohost app checkurl $domain$path -a $app \
- || ynh_die "The path ${domain}${path} is not available for app installation."
+# Create a dedicated NGINX config
+ynh_add_nginx_config
-# Check user parameter
-ynh_user_exists "$admin" \
- || ynh_die "The chosen admin user does not exist."
-ynh_app_setting_set $app admin_user $admin
+# Create a dedicated systemd config
+ynh_add_systemd_config
-# Check destination directory
-DESTDIR="/var/www/$app"
-[[ -d $DESTDIR ]] && ynh_die \
-"The destination directory '$DESTDIR' already exists.\
- You should safely delete it before installing this app."
+yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log"
-# Define app's data directory
-DATADIR="/home/yunohost.app/${app}/data"
+#=================================================
+# ADD A CONFIGURATION
+#=================================================
+#ynh_script_progression --message="Adding a configuration file..." --weight=1
-# Install dependencies
-ynh_package_install_from_equivs ../conf/${DEPS_PKG_NAME}.control \
- || ynh_die "Unable to install dependencies"
+#ynh_add_config --template="../conf/.env" --destination="$install_dir/.env"
-# Generate random password
-dbpass=$(ynh_string_random)
+#chmod 600 "$install_dir/.env"
+#chown $app:$app "$install_dir/.env"
-# Initialize database
-ynh_mysql_create_db $dbname $dbuser $dbpass
+#=================================================
+# INSTALL OWNCLOUD
+#=================================================
+ynh_script_progression --message="Installing $app..." --weight=3
-# Create a system account for ownCloud
-sudo useradd -c "$app system account" \
- -d /var/lib/$app --system --user-group $app \
- || ynh_die "Unable to create $app system account"
+(cd "$install_dir" && ./owncloud init --insecure=true --force-overwrite=true --admin-password=$password --config-path=$install_dir/.ocis/config)
-# Set system group in hooks
-sed -i "s@#GROUP#@${app}@g" ../hooks/post_user_create
+chmod 750 "$install_dir"
+chmod -R o-rwx "$install_dir"
+chown -R $app:www-data "$install_dir"
-# Create app folders
-sudo mkdir -p "$DESTDIR" "$DATADIR"
+#=================================================
+# START SYSTEMD SERVICE
+#=================================================
+ynh_script_progression --message="Starting a systemd service..." --weight=1
-# Copy ownCloud configuration file
-oc_conf="${DESTDIR}/config.json"
-sed -i "s@#DOMAIN#@${domain}@g" ../conf/config.json
-sed -i "s@#DATADIR#@${DATADIR}@g" ../conf/config.json
-sudo cp ../conf/config.json "$oc_conf"
+# Start a systemd service
+ynh_systemd_action --service_name=$app --action="start" --log_path="systemd"
-# Copy and set nginx configuration
-nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf"
-sed -i "s@#APP#@${app}@g" ../conf/nginx.conf
-sed -i "s@#PATH#@${path}@g" ../conf/nginx.conf
-sed -i "s@#LOCATION#@${path:-/}@g" ../conf/nginx.conf
-sed -i "s@#DESTDIR#@${DESTDIR}@g" ../conf/nginx.conf
-# do not serve .well-known if it's already served on the domain
-if is_url_handled "https://${domain}/.well-known/caldav" ; then
- sed -ri '/^location = \/\.well\-known\/(caldav|carddav) \{/,/\}/d' \
- ../conf/nginx.conf
-fi
-sudo cp ../conf/nginx.conf "$nginx_conf"
+#=================================================
+# END OF SCRIPT
+#=================================================
-# Copy and set php-fpm configuration
-phpfpm_conf="/etc/php5/fpm/pool.d/${app}.conf"
-sed -i "s@#USER#@${app}@g" ../conf/php-fpm.conf
-sed -i "s@#GROUP#@${app}@g" ../conf/php-fpm.conf
-sed -i "s@#POOLNAME#@${app}@g" ../conf/php-fpm.conf
-sed -i "s@#DESTDIR#@${DESTDIR}/@g" ../conf/php-fpm.conf
-sudo cp ../conf/php-fpm.conf "$phpfpm_conf"
-sudo chown root: $phpfpm_conf
-sudo chmod 644 $phpfpm_conf
-
-# occ helper for the current installation
-_exec_occ() {
- exec_occ "$DESTDIR" "$app" $@
-}
-
-# Set app folders ownership
-sudo chown -R $app: "$DESTDIR" "$DATADIR"
-
-# Retrieve ownCloud sources
-extract_owncloud "$DESTDIR" "$app"
-
-# Install ownCloud using a temporary admin user
-_exec_occ maintenance:install \
- --database "mysql" --database-name "$dbname" \
- --database-user "$dbuser" --database-pass "$dbpass" \
- --admin-user "admin" --admin-pass "$(ynh_string_random 6)" \
- --data-dir "$DATADIR" \
- || ynh_die "Unable to install ownCloud"
-
-# Enable plugins and set ownCloud configuration
-_exec_occ app:enable user_ldap
-_exec_occ ldap:create-empty-config
-_exec_occ config:import "$oc_conf"
-sudo rm -f "$oc_conf"
-
-# Check LDAP configuratio to see if everything worked well
-_exec_occ ldap:test-config \'\' \
- || ynh_die "An error occured during LDAP configuration"
-
-# Enable External Storage and create local mount to home folder
-if [[ $user_home -eq 1 ]]; then
- _exec_occ app:enable files_external
- _exec_occ files_external:create \
- 'Home' 'local' 'null::null' -c 'datadir=/home/$user'
-fi
-
-# Add dynamic logout URL to the config
-_exec_occ config:system:get logout_url >/dev/null 2>&1 \
- || sudo su -c "echo \"
-//-YunoHost-
-// set logout_url according to main domain
-\\\$main_domain = exec('cat /etc/yunohost/current_host');
-\\\$CONFIG['logout_url'] = 'https://'.\\\$main_domain.'/yunohost/sso/?action=logout';
-//-YunoHost-
-\" >> ${DESTDIR}/config/config.php" -- $app
-
-# Set the user as admin and delete admin user
-ynh_mysql_connect_as $dbuser $dbpass $dbname \
- <<< "INSERT INTO oc_group_user VALUES ('admin','$admin');"
-_exec_occ user:delete admin
-
-# Iterate over users to extend their home folder permissions - for the external
-# storage plugin usage - and create relevant ownCloud directories
-for u in $(ynh_user_list); do
- sudo mkdir -p "${DATADIR}/${u}"
- sudo setfacl -m g:$app:rwx "/home/$u" || true
-done
-
-# Fix app ownerships & permissions
-sudo chown -R $app: "$DESTDIR" "$DATADIR"
-sudo find ${DESTDIR}/ -type f -print0 | sudo xargs -0 chmod 0644
-sudo find ${DESTDIR}/ -type d -print0 | sudo xargs -0 chmod 0755
-sudo find ${DATADIR}/ -type f -print0 | sudo xargs -0 chmod 0640
-sudo find ${DATADIR}/ -type d -print0 | sudo xargs -0 chmod 0750
-sudo chmod 640 "${DESTDIR}/config/config.php"
-sudo chmod 755 /home/yunohost.app
-
-# Store app settings
-ynh_app_setting_set "$app" user_home "$user_home"
-ynh_app_setting_set "$app" mysqlpwd "$dbpass"
-
-# Set SSOwat rules
-ynh_app_setting_set "$app" unprotected_uris "/"
-ynh_app_setting_set "$app" skipped_regex \
- "$(sed 's/[\.\-]/\%&/g' <<< $domain)/%.well%-known/.*"
-
-# Reload services
-sudo service php5-fpm restart || true
-sudo service nginx reload || true
-
-# Add cron job
-cron_path="/etc/cron.d/$app"
-sed -i "s@#USER#@${app}@g" ../conf/owncloud.cron
-sed -i "s@#DESTDIR#@${DESTDIR}@g" ../conf/owncloud.cron
-sudo cp ../conf/owncloud.cron "$cron_path"
-sudo chmod 644 "$cron_path"
-_exec_occ background:cron
+ynh_script_progression --message="Installation of $app completed" --last
diff --git a/scripts/remove b/scripts/remove
index d1957f5..57324bf 100755
--- a/scripts/remove
+++ b/scripts/remove
@@ -1,48 +1,35 @@
#!/bin/bash
-# Get multi-instances specific variables
-app=$YNH_APP_INSTANCE_NAME
+#=================================================
+# GENERIC START
+#=================================================
+# IMPORT GENERIC HELPERS
+#=================================================
-# Set app specific variables
-dbname=$app
-dbuser=$app
+source _common.sh
+source /usr/share/yunohost/helpers
-# Load common variables and helpers
-. ./_common.sh
+#=================================================
+# STANDARD REMOVE
+#=================================================
+# REMOVE SERVICE INTEGRATION IN YUNOHOST
+#=================================================
-# Source app helpers
-. /usr/share/yunohost/helpers
+# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
+if ynh_exec_warn_less yunohost service status $app >/dev/null
+then
+ ynh_script_progression --message="Removing $app service integration..." --weight=1
+ yunohost service remove $app
+fi
-# Remove cron job
-# TODO: Ensure that cron job is not running
-sudo rm -f "/etc/cron.d/${app}"
+# Remove the dedicated systemd config
+ynh_remove_systemd_config
-# Drop MySQL database and user
-ynh_mysql_drop_db "$dbname" 2>/dev/null || true
-ynh_mysql_drop_user "$dbuser" 2>/dev/null || true
+# Remove the dedicated NGINX config
+ynh_remove_nginx_config
-# Retrieve domain from app settings
-domain=$(ynh_app_setting_get $app domain)
+#=================================================
+# END OF SCRIPT
+#=================================================
-# Delete app directory and configurations
-sudo rm -rf "/var/www/${app}"
-sudo rm -f "/etc/php5/fpm/pool.d/${app}.conf"
-[[ -n $domain ]] && sudo rm -f "/etc/nginx/conf.d/${domain}.d/${app}.conf"
-
-# Reload services
-sudo service php5-fpm restart || true
-sudo service nginx reload || true
-
-# Remove app dependencies
-ynh_package_autoremove "$DEPS_PKG_NAME" || true
-
-# Clean home folders ACLs
-for i in $(ls /home); do
- [[ ! $i == yunohost.* ]] \
- && sudo setfacl -x g:$app:rwx >/dev/null 2>&1
-done
-
-# Remove the user account
-id "$app" >/dev/null 2>&1 \
- && sudo deluser --quiet --remove-home "$app" >/dev/null \
- || true
+ynh_script_progression --message="Removal of $app completed" --last
diff --git a/scripts/restore b/scripts/restore
index 39d540f..165968f 100755
--- a/scripts/restore
+++ b/scripts/restore
@@ -1,86 +1,66 @@
#!/bin/bash
-set -eu
+#=================================================
+# GENERIC START
+#=================================================
+# IMPORT GENERIC HELPERS
+#=================================================
-# Get multi-instances specific variables
-app=$YNH_APP_INSTANCE_NAME
+# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
+source ../settings/scripts/_common.sh
+source /usr/share/yunohost/helpers
-# Set app specific variables
-dbname=$app
-dbuser=$app
+#=================================================
+# RESTORE THE APP MAIN DIR
+#=================================================
+ynh_script_progression --message="Restoring the app main directory..." --weight=1
-# Source app helpers
-. /usr/share/yunohost/helpers
+ynh_restore_file --origin_path="$install_dir"
-# Retrieve old app settings
-domain=$(ynh_app_setting_get $app domain)
-path=$(ynh_app_setting_get $app path)
-dbpass=$(ynh_app_setting_get $app mysqlpwd)
+chmod 750 "$install_dir"
+chmod -R o-rwx "$install_dir"
+chown -R $app:www-data "$install_dir"
+chmod +x $install_dir/owncloud
-# TODO: Check domain/path availability with app helper
-sudo yunohost app checkurl $domain$path -a $app \
- || ynh_die "The path ${domain}${path} is not available for app installation."
+#=================================================
+# RESTORE THE DATA DIRECTORY
+#=================================================
+ynh_script_progression --message="Restoring the data directory..." --weight=1
-# Check destination directory
-DESTDIR="/var/www/$app"
-[[ -d $DESTDIR ]] && ynh_die \
-"The destination directory '$DESTDIR' already exists.\
- You should safely delete it before restoring this app."
+ynh_restore_file --origin_path="$data_dir" --not_mandatory
-# Define app's data directory
-DATADIR="/home/yunohost.app/${app}/data"
+chown -R $app:www-data "$data_dir"
-# Check configuration files
-nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf"
-[[ -f $nginx_conf ]] && ynh_die \
-"The NGINX configuration already exists at '${nginx_conf}'.
- You should safely delete it before restoring this app."
-phpfpm_conf="/etc/php5/fpm/pool.d/${app}.conf"
-[[ -f $phpfpm_conf ]] && ynh_die \
-"The PHP FPM configuration already exists at '${phpfpm_conf}'.
- You should safely delete it before restoring this app."
+#=================================================
+# RESTORE THE NGINX CONFIGURATION
+#=================================================
+ynh_script_progression --message="Restoring the NGINX web server configuration..." --time --weight=1
-# Install dependencies
-ynh_package_install_from_equivs ./owncloud-deps.control \
- || ynh_die "Unable to install dependencies"
+ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
-# Create a system account for ownCloud
-sudo useradd -c "$app system account" \
- -d /var/lib/$app --system --user-group $app \
- || ynh_die "Unable to create $app system account"
+ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
+systemctl enable $app.service --quiet
-# Restore the app files
-sudo cp -a ./www "$DESTDIR"
-sudo mkdir -p "$DATADIR"
-sudo cp -a ./data/. "$DATADIR"
+yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log"
-# Create and restore the database
-ynh_mysql_create_db $dbname $dbuser $dbpass
-ynh_mysql_connect_as $dbuser $dbpass $dbname < ./db.sql
+#=================================================
+# START SYSTEMD SERVICE
+#=================================================
+ynh_script_progression --message="Starting a systemd service..." --weight=1
-# Iterate over users to extend their home folder permissions - for the external
-# storage plugin usage - and create relevant ownCloud directories
-for u in $(ynh_user_list); do
- sudo mkdir -p "${DATADIR}/${u}"
- sudo setfacl -m g:$app:rwx "/home/$u" || true
-done
+ynh_systemd_action --service_name=$app --action="start" --log_path="systemd"
-# Fix app ownerships & permissions
-sudo chown -R $app: "$DESTDIR" "$DATADIR"
-sudo find ${DESTDIR}/ -type f -print0 | sudo xargs -0 chmod 0644
-sudo find ${DESTDIR}/ -type d -print0 | sudo xargs -0 chmod 0755
-sudo find ${DATADIR}/ -type f -print0 | sudo xargs -0 chmod 0640
-sudo find ${DATADIR}/ -type d -print0 | sudo xargs -0 chmod 0750
-sudo chmod 640 "${DESTDIR}/config/config.php"
-sudo chmod 755 /home/yunohost.app
+#=================================================
+# GENERIC FINALIZATION
+#=================================================
+# RELOAD NGINX AND PHP-FPM
+#=================================================
+ynh_script_progression --message="Reloading NGINX web server..." --weight=1
-# Restore configuration files
-sudo cp -a ./conf/nginx.conf "$nginx_conf"
-sudo cp -a ./conf/php-fpm.conf "$phpfpm_conf"
+ynh_systemd_action --service_name=nginx --action=reload
-# Restore cron job
-sudo cp -a ./conf/cron "/etc/cron.d/${app}"
+#=================================================
+# END OF SCRIPT
+#=================================================
-# Reload services
-sudo service php5-fpm restart || true
-sudo service nginx reload || true
+ynh_script_progression --message="Restoration completed for $app" --last
diff --git a/scripts/upgrade b/scripts/upgrade
old mode 100755
new mode 100644
index 6896935..a591b3c
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -1,177 +1,85 @@
#!/bin/bash
-set -eu
+#=================================================
+# GENERIC START
+#=================================================
+# IMPORT GENERIC HELPERS
+#=================================================
-# Get multi-instances specific variables
-app=$YNH_APP_INSTANCE_NAME
+source _common.sh
+source /usr/share/yunohost/helpers
-# Load common variables and helpers
-. ./_common.sh
+#=================================================
+# CHECK VERSION
+#=================================================
-# Set app specific variables
-dbname=$app
-dbuser=$app
+upgrade_type=$(ynh_check_app_version_changed)
-# Source app helpers
-. /usr/share/yunohost/helpers
+#=================================================
+# STANDARD UPGRADE STEPS
+#=================================================
+# STOP SYSTEMD SERVICE
+#=================================================
+ynh_script_progression --message="Stopping a systemd service..." --weight=1
-# Retrieve app settings
-domain=$(ynh_app_setting_get "$app" domain)
-path=$(ynh_app_setting_get "$app" path)
-path=${path%/}
-dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
-user_home=$(ynh_app_setting_get "$app" user_home)
+ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd"
-# Check destination directory
-DESTDIR="/var/www/$app"
-[[ ! -d $DESTDIR ]] && ynh_die \
-"The destination directory '$DESTDIR' does not exist.\
- The app is not correctly installed, you should remove it first."
+#=================================================
+# DOWNLOAD, CHECK AND UNPACK SOURCE
+#=================================================
-# Check app's data directory
-DATADIR="/home/yunohost.app/${app}/data"
-[[ ! -d $DATADIR ]] && ynh_die \
-"The data directory '$DATADIR' does not exist.\
- The app is not correctly installed, you should remove it first."
+if [ "$upgrade_type" == "UPGRADE_APP" ]
+then
+ ynh_script_progression --message="Upgrading source files..." --weight=1
-# Upgrade dependencies
-ynh_package_install_from_equivs ../conf/${DEPS_PKG_NAME}.control \
- || ynh_die "Unable to upgrade dependencies"
-
-# FIXME: Delete current nginx configuration to be able to check if
-# .well-known is already served. See https://dev.yunohost.org/issues/400
-nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf"
-sudo rm -f "$nginx_conf"
-sudo service nginx reload
-
-# Copy and set nginx configuration
-sed -i "s@#APP#@${app}@g" ../conf/nginx.conf
-sed -i "s@#PATH#@${path}@g" ../conf/nginx.conf
-sed -i "s@#LOCATION#@${path:-/}@g" ../conf/nginx.conf
-sed -i "s@#DESTDIR#@${DESTDIR}@g" ../conf/nginx.conf
-# do not serve .well-known if it's already served on the domain
-if is_url_handled "https://${domain}/.well-known/caldav" ; then
- sed -ri '/^location = \/\.well\-known\/(caldav|carddav) \{/,/\}/d' \
- ../conf/nginx.conf
-fi
-sudo cp ../conf/nginx.conf "$nginx_conf"
-
-# Copy and set php-fpm configuration
-phpfpm_conf="/etc/php5/fpm/pool.d/${app}.conf"
-sed -i "s@#USER#@${app}@g" ../conf/php-fpm.conf
-sed -i "s@#GROUP#@${app}@g" ../conf/php-fpm.conf
-sed -i "s@#POOLNAME#@${app}@g" ../conf/php-fpm.conf
-sed -i "s@#DESTDIR#@${DESTDIR}/@g" ../conf/php-fpm.conf
-sudo cp ../conf/php-fpm.conf "$phpfpm_conf"
-sudo chown root: $phpfpm_conf
-sudo chmod 644 $phpfpm_conf
-
-# Set system group in hooks
-sed -i "s@#GROUP#@${app}@g" ../hooks/post_user_create
-
-# occ helper for the current installation
-_exec_occ() {
- exec_occ "$DESTDIR" "$app" $@
-}
-
-# Retrieve new ownCloud sources in a temporary directory
-TMPDIR=$(ynh_mkdir_tmp)
-extract_owncloud "$TMPDIR"
-
-# Copy ownCloud configuration file
-oc_conf="${DESTDIR}/config.json"
-sed -i "s@#DOMAIN#@${domain}@g" ../conf/config.json
-sed -i "s@#DATADIR#@${DATADIR}@g" ../conf/config.json
-sudo cp ../conf/config.json "${TMPDIR}/config.json"
-
-# Enable maintenance mode
-_exec_occ maintenance:mode --on
-
-# Copy config and 3rd party applications from current directory
-sudo cp -a "${DESTDIR}/config/config.php" "${TMPDIR}/config/config.php"
-for a in $(sudo ls "${DESTDIR}/apps"); do
- [[ ! -d "${TMPDIR}/apps/$a" ]] \
- && sudo cp -a "${DESTDIR}/apps/$a" "${TMPDIR}/apps/$a"
-done
-
-# Rename existing app directory and move new one
-sudo rm -rf "${DESTDIR}"
-sudo mv "$TMPDIR" "$DESTDIR"
-
-# Set app folders ownership
-sudo chown -R $app: "$DESTDIR" "$DATADIR"
-
-# Upgrade ownCloud (SUCCESS = 0, UP_TO_DATE = 3)
-# TODO: Restore old directory in case of failure?
-_exec_occ maintenance:mode --off
-_exec_occ upgrade \
- || ([[ $? -eq 3 ]] || ynh_die "Unable to upgrade ownCloud")
-
-# Enable plugins and set ownCloud configuration
-_exec_occ app:enable user_ldap
-_exec_occ config:import "$oc_conf"
-sudo rm -f "$oc_conf"
-
-# Guess user_home value if empty
-if [[ -z "${user_home:-}" ]]; then
- sudo cat "${DATADIR}/mount.json" >/dev/null 2>&1 \
- && user_home=1 \
- || user_home=0
- ynh_app_setting_set "$app" user_home "$user_home"
+ # Download, check integrity, uncompress and patch the source from app.src
+ ynh_setup_source --dest_dir="$install_dir"
fi
-# Enable External Storage and create local mount to home folder as needed
-if [[ ${user_home} -eq 1 ]]; then
- _exec_occ app:enable files_external
- _exec_occ files_external:list --output=json \
- | grep -q '"storage":"\\\\OC\\\\Files\\\\Storage\\\\Local"' \
- || _exec_occ files_external:create \
- 'Home' 'local' 'null::null' -c 'datadir=/home/$user'
-fi
+chmod 750 "$install_dir"
+chmod -R o-rwx "$install_dir"
+chown -R $app:www-data "$install_dir"
-# Add dynamic logout URL to the config
-# TODO: if changes are made to this section, replace it with new one.
-_exec_occ config:system:get logout_url >/dev/null 2>&1 \
- || sudo su -c "echo \"
-//-YunoHost-
-// set logout_url according to main domain
-\\\$main_domain = exec('cat /etc/yunohost/current_host');
-\\\$CONFIG['logout_url'] = 'https://'.\\\$main_domain.'/yunohost/sso/?action=logout';
-//-YunoHost-
-\" >> ${DESTDIR}/config/config.php" -- $app
+#=================================================
+# PHP-FPM CONFIGURATION
+#=================================================
+ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=1
-# Iterate over users to extend their home folder permissions - for the external
-# storage plugin usage - and create relevant ownCloud directories
-for u in $(ynh_user_list); do
- sudo mkdir -p "${DATADIR}/${u}"
- sudo setfacl -m g:$app:rwx "/home/$u" || true
-done
+# Create a dedicated PHP-FPM config
+ynh_add_fpm_config
-# Fix app ownerships & permissions
-sudo find ${DESTDIR}/ -type f -print0 | sudo xargs -0 chmod 0644
-sudo find ${DESTDIR}/ -type d -print0 | sudo xargs -0 chmod 0755
-sudo find ${DATADIR}/ -type f -print0 | sudo xargs -0 chmod 0640
-sudo find ${DATADIR}/ -type d -print0 | sudo xargs -0 chmod 0750
-sudo chmod 640 "${DESTDIR}/config/config.php"
-sudo chmod 755 /home/yunohost.app
+# Create a dedicated NGINX config
+ynh_add_nginx_config
-# Set SSOwat rules
-ynh_app_setting_set "$app" unprotected_uris "/"
-ynh_app_setting_set "$app" skipped_regex \
- "$(sed 's/[\.\-]/\%&/g' <<< $domain)/%.well%-known/.*"
+#=================================================
+# UPDATE A CONFIG FILE
+#=================================================
+ynh_script_progression --message="Updating a configuration file..." --weight=1
-# Reload services
-sudo service php5-fpm restart || true
-sudo service nginx reload || true
+ynh_add_config --template="some_config_file" --destination="$install_dir/some_config_file"
-# Add cron job
-cron_path="/etc/cron.d/$app"
-sed -i "s@#USER#@${app}@g" ../conf/owncloud.cron
-sed -i "s@#DESTDIR#@${DESTDIR}@g" ../conf/owncloud.cron
-sudo cp ../conf/owncloud.cron "$cron_path"
-sudo chmod 644 "$cron_path"
-_exec_occ background:cron
+chmod 400 "$install_dir/some_config_file"
+chown $app:$app "$install_dir/some_config_file"
-# Warn about possible disabled apps
-echo "Note that if you've installed some third-parties ownCloud applications, \
-they are probably disabled and you'll have to manually activate them again." >&2
+#=================================================
+# SETUP SYSTEMD
+#=================================================
+ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
+
+# Create a dedicated systemd config
+ynh_add_systemd_config
+
+yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log"
+
+#=================================================
+# START SYSTEMD SERVICE
+#=================================================
+ynh_script_progression --message="Starting a systemd service..." --weight=1
+
+ynh_systemd_action --service_name=$app --action="start" --log_path="systemd"
+
+#=================================================
+# END OF SCRIPT
+#=================================================
+
+ynh_script_progression --message="Upgrade of $app completed" --last
diff --git a/sources/extra_files/app/.gitignore b/sources/extra_files/app/.gitignore
new file mode 100644
index 0000000..783a4ae
--- /dev/null
+++ b/sources/extra_files/app/.gitignore
@@ -0,0 +1,2 @@
+*~
+*.sw[op]
diff --git a/sources/patches/.gitignore b/sources/patches/.gitignore
new file mode 100644
index 0000000..783a4ae
--- /dev/null
+++ b/sources/patches/.gitignore
@@ -0,0 +1,2 @@
+*~
+*.sw[op]