Browse Source

Initial commit

opi 9 years ago
commit
914b85a251
6 changed files with 171 additions and 0 deletions
  1. 10 0
      README.md
  2. 25 0
      conf/nginx.conf
  3. 48 0
      manifest.json
  4. 38 0
      scripts/install
  5. 18 0
      scripts/remove
  6. 32 0
      scripts/upgrade

+ 10 - 0
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.

+ 25 - 0
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;
+}

+ 48 - 0
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"
+            }
+        ]
+    }
+}

+ 38 - 0
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

+ 18 - 0
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

+ 32 - 0
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
+