commit c96acfff0f66f70e9b6fe48d4f833896259f794a Author: opi Date: Sun Feb 1 03:21:28 2015 +0100 Initial commit. diff --git a/README.md b/README.md new file mode 100644 index 0000000..82059a8 --- /dev/null +++ b/README.md @@ -0,0 +1,10 @@ +# YunoHost example app # + +## Usage ## +- Add application source files into `sources` subfolder. +- Edit `conf/nginx.conf` file to match application prerequisites. +- Edit manifest with application specific information. +- Edit the install/upgrade/remove scripts. + +**More information on the documentation page:** +https://yunohost.org/packaging_apps diff --git a/conf/nginx.conf b/conf/nginx.conf new file mode 100644 index 0000000..8ec2b2d --- /dev/null +++ b/conf/nginx.conf @@ -0,0 +1,13 @@ +location YNH_WWW_PATH { + alias YNH_WWW_ALIAS ; + + # Force https + if ($scheme = http) { + rewrite ^ https://$server_name$request_uri? permanent; + } + + index index.html; + + # Include SSOWAT user panel. + include conf.d/yunohost_panel.conf.inc; +} diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..05ebf01 --- /dev/null +++ b/manifest.json @@ -0,0 +1,42 @@ +{ + "name": "Anarchism", + "id": "anarchism", + "description": { + "en": "An exhaustive exploration of Anarchist theory and practice.", + "fr": "Exploration exhaustive de la théorie et de la pratique anarchiste." + }, + "licence": "GPL-2", + "developer": { + "name": "opi", + "email": "opi@zeropi.net", + "url": "http://zeropi.net" + }, + "multi_instance": "false", + "arguments": { + "install" : [ + { + "name": "domain", + "ask": { + "en": "Choose a domain for anarchism" + }, + "example": "example.com" + }, + { + "name": "path", + "ask": { + "en": "Choose a path for anarchism" + }, + "example": "/anarchism", + "default": "/anarchism" + }, + { + "name": "is_public", + "ask": { + "en": "Is it a public website ?" + }, + "choices": ["Yes", "No"], + "default": "Yes" + } + ] + } +} diff --git a/scripts/backup b/scripts/backup new file mode 100644 index 0000000..8a822d7 --- /dev/null +++ b/scripts/backup @@ -0,0 +1,12 @@ +#!/bin/bash +app=anarchism + +# The parameter $1 is the backup directory location +# which will be compressed afterward +backup_dir=$1/apps/$app +mkdir -p $backup_dir + +# Copy Nginx and YunoHost parameters to make the script "standalone" +sudo cp -a /etc/yunohost/apps/$app/. $backup_dir/yunohost +domain=$(sudo yunohost app setting $app domain) +sudo cp -a /etc/nginx/conf.d/$domain.d/$app.conf $backup_dir/nginx.conf diff --git a/scripts/install b/scripts/install new file mode 100755 index 0000000..bba3dcd --- /dev/null +++ b/scripts/install @@ -0,0 +1,35 @@ +#!/bin/bash +app=anarchism + +# Retrieve arguments +domain=$1 +path=$2 +is_public=$3 + +# Save app settings +sudo yunohost app setting $app is_public -v "$is_public" + +# Check domain/path availability +sudo yunohost app checkurl $domain$path -a $app +if [[ ! $? -eq 0 ]]; then + exit 1 +fi + +# Install anarchism package +sudo apt-get install anarchism + +# Modify Nginx configuration file and copy it to Nginx conf directory +sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf +sed -i "s@YNH_WWW_ALIAS@$final_path/@g" ../conf/nginx.conf +sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf + +# If app is public, add url to SSOWat conf as skipped_uris +if [ "$is_public" = "Yes" ]; +then + # unprotected_uris allows SSO credentials to be passed anyway. + sudo yunohost app setting $app unprotected_uris -v "/" +fi + +# Restart services +sudo service nginx reload +sudo yunohost app ssowatconf diff --git a/scripts/remove b/scripts/remove new file mode 100755 index 0000000..298245d --- /dev/null +++ b/scripts/remove @@ -0,0 +1,17 @@ +#!/bin/bash +app=anarchism + +# Retrieve arguments +domain=$(sudo yunohost app setting $app domain) +path=$(sudo yunohost app setting $app path) +is_public=$(sudo yunohost app setting $app is_public) + +# Remove sources +sudo apt-get remove anarchism + +# Remove configuration files +sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf + +# Restart services +sudo service nginx reload +sudo yunohost app ssowatconf diff --git a/scripts/restore b/scripts/restore new file mode 100644 index 0000000..ad204cf --- /dev/null +++ b/scripts/restore @@ -0,0 +1,13 @@ +#!/bin/bash +app=anarchism + +# The parameter $1 is the uncompressed restore directory location +backup_dir=$1/apps/$app + +# Restore Nginx and YunoHost parameters +sudo cp -a $backup_dir/yunohost/. /etc/yunohost/apps/$app +domain=$(sudo yunohost app setting $app domain) +sudo cp -a $backup_dir/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf + +# Restart webserver +sudo service nginx reload diff --git a/scripts/upgrade b/scripts/upgrade new file mode 100755 index 0000000..4089cce --- /dev/null +++ b/scripts/upgrade @@ -0,0 +1,33 @@ +#!/bin/bash +app=anarchism + +# Retrieve arguments +domain=$(sudo yunohost app setting $app domain) +path=$(sudo yunohost app setting $app path) +is_public=$(sudo yunohost app setting $app is_public) + +# Remove trailing "/" for next commands +path=${path%/} + +# Upgrade anarchism package +sudo apt-get update +sudo apt-get upgrade anarchism + +# Modify Nginx configuration file and copy it to Nginx conf directory +sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf +sed -i "s@YNH_WWW_ALIAS@$final_path/@g" ../conf/nginx.conf +sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf + +# If app is public, add url to SSOWat conf as skipped_uris +if [ "$is_public" = "Yes" ]; +then + # See install script + sudo yunohost app setting $app unprotected_uris -v "/" + # Remove old settings + sudo yunohost app setting $app skipped_uris -d +fi + +# Restart services +sudo service nginx reload +sudo yunohost app ssowatconf +