From 914b85a2516a132ab356a9751120da6ce9b0f91c Mon Sep 17 00:00:00 2001 From: opi Date: Mon, 20 Oct 2014 18:55:53 +0200 Subject: [PATCH] Initial commit --- README.md | 10 ++++++++++ conf/nginx.conf | 25 +++++++++++++++++++++++++ manifest.json | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ scripts/install | 38 ++++++++++++++++++++++++++++++++++++++ scripts/remove | 18 ++++++++++++++++++ scripts/upgrade | 32 ++++++++++++++++++++++++++++++++ 6 files changed, 171 insertions(+) create mode 100644 README.md create mode 100644 conf/nginx.conf create mode 100644 manifest.json create mode 100755 scripts/install create mode 100755 scripts/remove create mode 100755 scripts/upgrade diff --git a/README.md b/README.md new file mode 100644 index 0000000..6dbabb3 --- /dev/null +++ b/README.md @@ -0,0 +1,10 @@ +# YunoHost Application example # + +## Documentation ## +https://yunohost.org/packaging_apps_en + +## Usage ## +- Add application source files into `sources` subfolder. +- Edit `conf/nginx.conf` file to match application prerequisites. +- Edit install/upgrade/remove scripts. +- Edit manifest with application specific information. \ No newline at end of file diff --git a/conf/nginx.conf b/conf/nginx.conf new file mode 100644 index 0000000..c99f4ff --- /dev/null +++ b/conf/nginx.conf @@ -0,0 +1,25 @@ +location YNH_EXAMPLE_PATH { + + # Path to source + alias YNH_EXAMPLE_ALIAS ; + + # Force https + if ($scheme = http) { + rewrite ^ https://$server_name$request_uri? permanent; + } + + # Example PHP configuration + index index.php; + try_files $uri $uri/ index.php; + location ~ [^/]\.php(/|$) { + fastcgi_split_path_info ^(.+?\.php)(/.*)$; + fastcgi_pass unix:/var/run/php5-fpm.sock; + fastcgi_index index.php; + include fastcgi_params; + fastcgi_param REMOTE_USER $remote_user; + fastcgi_param PATH_INFO $fastcgi_path_info; + } + + # 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..fdf4463 --- /dev/null +++ b/manifest.json @@ -0,0 +1,48 @@ +{ + "name": "YunoHost application example", + "id": "ynhexample", + "description": { + "en": "Example package for Yunohost applications." + }, + "licence": "GPL-2", + "developer": { + "name": "John doe", + "email": "john.doe@example.com", + "url": "http://example.com" + }, + "multi_instance": "false", + "arguments": { + "install" : [ + { + "name": "domain", + "ask": { + "en": "Choose a domain for ynhexample" + }, + "example": "example.com" + }, + { + "name": "path", + "ask": { + "en": "Choose a path for ynhexample" + }, + "example": "/dokuwiki", + "default": "/dokuwiki" + }, + { + "name": "admin", + "ask": { + "en": "Choose an admin user" + }, + "example": "johndoe" + }, + { + "name": "is_public", + "ask": { + "en": "Is it a public application ?" + }, + "choices": ["Yes", "No"], + "default": "Yes" + } + ] + } +} diff --git a/scripts/install b/scripts/install new file mode 100755 index 0000000..366f283 --- /dev/null +++ b/scripts/install @@ -0,0 +1,38 @@ +#!/bin/bash +app=ynhexample + +# Retrieve arguments +domain=$1 +path=$2 +admin=$3 +is_public=$4 + +# Save app settings +sudo yunohost app setting $app admin -v "$admin" +sudo yunohost app setting $app is_public -v "$is_public" + +# Check domain/path availability +sudo yunohost app checkurl $domain$path -a dokuwiki +if [[ ! $? -eq 0 ]]; then + exit 1 +fi + +# Copy source files +final_path=/var/www/$app +sudo mkdir -p $final_path +sudo cp -a ../sources/* $final_path + +# 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 + sudo yunohost app setting $app skipped_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..748bb92 --- /dev/null +++ b/scripts/remove @@ -0,0 +1,18 @@ +#!/bin/bash +app=ynhexample + +# Retrieve arguments +domain=$(sudo yunohost app setting $app domain) +path=$(sudo yunohost app setting $app path) +admin=$(sudo yunohost app setting $app admin) +is_public=$(sudo yunohost app setting $app is_public) + +# Remove sources +sudo rm -rf /var/www/$app + +# 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/upgrade b/scripts/upgrade new file mode 100755 index 0000000..f3a5ac5 --- /dev/null +++ b/scripts/upgrade @@ -0,0 +1,32 @@ +#!/bin/bash +app=ynhexample + +# Retrieve arguments +domain=$(sudo yunohost app setting $app domain) +path=$(sudo yunohost app setting $app path) +admin=$(sudo yunohost app setting $app admin) +is_public=$(sudo yunohost app setting $app is_public) + +# Remove trailing "/" for next commands +path=${path%/} + +# Copy source files +final_path=/var/www/$app +sudo mkdir -p $final_path +sudo cp -a ../sources/* $final_path + +# 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 + sudo yunohost app setting $app skipped_uris -v "/" +fi + +# Restart services +sudo service nginx reload +sudo yunohost app ssowatconf +