1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/anarchism_ynh.git synced 2024-09-03 18:05:55 +02:00

Initial commit.

This commit is contained in:
opi 2015-02-01 03:21:28 +01:00
commit c96acfff0f
8 changed files with 175 additions and 0 deletions

10
README.md Normal file
View file

@ -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

13
conf/nginx.conf Normal file
View file

@ -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;
}

42
manifest.json Normal file
View file

@ -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"
}
]
}
}

12
scripts/backup Normal file
View file

@ -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

35
scripts/install Executable file
View file

@ -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

17
scripts/remove Executable file
View file

@ -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

13
scripts/restore Normal file
View file

@ -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

33
scripts/upgrade Executable file
View file

@ -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