mirror of
https://github.com/YunoHost/example_ynh.git
synced 2024-09-03 20:06:13 +02:00
Merge 5d4c205bf9
into 7c82a96ca3
This commit is contained in:
commit
fd70553a93
11 changed files with 318 additions and 244 deletions
12
README.md
12
README.md
|
@ -1,11 +1,5 @@
|
||||||
# YunoHost example app
|
# Cagette app
|
||||||
|
|
||||||
## Usage
|
##Premiers pas
|
||||||
- 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, backup, restore scripts.
|
|
||||||
- Add a LICENSE file for the package.
|
|
||||||
|
|
||||||
**More information on the documentation page:**
|
- cette app est à l'état de test, il s'agit des premiers fichiers adaptés pour la plupart de https://github.com/YunoHost-Apps/my_webapp_ynh et de https://github.com/YunoHost/example_ynh
|
||||||
https://yunohost.org/packaging_apps
|
|
||||||
|
|
|
@ -1,33 +1,48 @@
|
||||||
location YNH_WWW_PATH {
|
location / {
|
||||||
|
alias /var/www/cagette_app/www/;
|
||||||
|
|
||||||
# Path to source
|
# Default indexes and catch-all
|
||||||
alias YNH_WWW_ALIAS ;
|
index index.html index.php;
|
||||||
|
try_files $uri $uri/ /index.php?$args;
|
||||||
|
|
||||||
# Example PHP configuration (remove if not used)
|
# Prevent useless logs
|
||||||
index index.php;
|
location = /favicon.ico {
|
||||||
|
log_not_found off;
|
||||||
|
access_log off;
|
||||||
|
}
|
||||||
|
location = /robots.txt {
|
||||||
|
allow all;
|
||||||
|
log_not_found off;
|
||||||
|
access_log off;
|
||||||
|
}
|
||||||
|
|
||||||
# Common parameter to increase upload size limit in conjuction with dedicated php-fpm file
|
# Deny access to hidden files and directories
|
||||||
#client_max_body_size 50M;
|
location ~ ^/(.+/|)\.(?!well-known\/) {
|
||||||
|
deny all;
|
||||||
|
}
|
||||||
|
|
||||||
try_files $uri $uri/ index.php;
|
# Execute and serve PHP files
|
||||||
location ~ [^/]\.php(/|$) {
|
location ~ [^/]\.php(/|$) {
|
||||||
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
||||||
fastcgi_pass unix:/var/run/php5-fpm.sock;
|
fastcgi_pass unix:/var/run/php5-fpm-my_webapp__2.sock;
|
||||||
|
fastcgi_index index.php;
|
||||||
# Filename to be changed if dedicated php-fpm process is required
|
include fastcgi_params;
|
||||||
# This is to be used INSTEAD of line above
|
fastcgi_param REMOTE_USER $remote_user;
|
||||||
# Don't forget to adjust scripts install/upgrade/remove/backup accordingly
|
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||||
#
|
fastcgi_param SCRIPT_FILENAME $request_filename;
|
||||||
#fastcgi_pass unix:/var/run/php5-fpm-YNH_WWW_APP.sock;
|
}
|
||||||
|
|
||||||
fastcgi_index index.php;
|
# Include SSOWAT user panel.
|
||||||
include fastcgi_params;
|
include conf.d/yunohost_panel.conf.inc;
|
||||||
fastcgi_param REMOTE_USER $remote_user;
|
|
||||||
fastcgi_param PATH_INFO $fastcgi_path_info;
|
location ~ \.(png|gif|jpg|ico|swf|css|js|dat)$ {
|
||||||
fastcgi_param SCRIPT_FILENAME $request_filename;
|
}
|
||||||
}
|
|
||||||
# PHP configuration end
|
location / {
|
||||||
|
rewrite (.*)/css/[a-z0-9]+/(.*) /css/$2 break;
|
||||||
|
rewrite (.*)/js/[a-z0-9]+/(.*) /js/$2 break;
|
||||||
|
rewrite ^(.*)$ /index.php;
|
||||||
|
}
|
||||||
|
|
||||||
# Include SSOWAT user panel.
|
|
||||||
include conf.d/yunohost_panel.conf.inc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
{
|
{
|
||||||
"name": "YunoHost example app",
|
"name": "cagette_app",
|
||||||
"id": "ynhexample",
|
"id": "cagette",
|
||||||
"packaging_format": 1,
|
"packaging_format": 1,
|
||||||
"description": {
|
"description": {
|
||||||
"en": "Example package for YunoHost application.",
|
"en": "Package for Cagette.net application in YunoHost.",
|
||||||
"fr": "Exemple de package d’application pour YunoHost."
|
"fr": "Package pour l’application Cagette.net pour YunoHost."
|
||||||
},
|
},
|
||||||
"url": "https://example.com",
|
"url": "http://www.cagette.net",
|
||||||
"license": "free",
|
"license": "free",
|
||||||
"maintainer": {
|
"maintainer": {
|
||||||
"name": "John doe",
|
"name": "Forissier Gaspard",
|
||||||
"email": "john.doe@example.com",
|
"email": "gaspard@garwinch.ddns.net",
|
||||||
"url": "http://example.com"
|
"url": "https://garwinch.ddns.net"
|
||||||
},
|
},
|
||||||
"requirements": {
|
"requirements": {
|
||||||
"yunohost": ">> 2.4.0"
|
"yunohost": ">> 2.4.0"
|
||||||
|
@ -28,20 +28,16 @@
|
||||||
"name": "domain",
|
"name": "domain",
|
||||||
"type": "domain",
|
"type": "domain",
|
||||||
"ask": {
|
"ask": {
|
||||||
"en": "Choose a domain name for ynhexample",
|
"en": "Choose a domain name for cagette_app",
|
||||||
"fr": "Choisissez un nom de domaine pour ynhexample"
|
"fr": "Choisissez un nom de domaine pour cagette_app"
|
||||||
},
|
},
|
||||||
"example": "example.com"
|
"example": "example.com"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "path",
|
"name": "path",
|
||||||
"type": "path",
|
"type": "path",
|
||||||
"ask": {
|
|
||||||
"en": "Choose a path for ynhexample",
|
"default": "/"
|
||||||
"fr": "Choisissez un chemin pour ynhexample"
|
|
||||||
},
|
|
||||||
"example": "/example",
|
|
||||||
"default": "/example"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "admin",
|
"name": "admin",
|
||||||
|
|
|
@ -3,31 +3,29 @@
|
||||||
# Exit on command errors and treat unset variables as an error
|
# Exit on command errors and treat unset variables as an error
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
# See comments in install script
|
# Get multi-instances specific variables
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
# Source YunoHost helpers
|
# Source app helpers
|
||||||
source /usr/share/yunohost/helpers
|
. /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# Backup sources & data
|
# Retrieve app settings
|
||||||
# Note: the last argument is where to save this path, see the restore script.
|
|
||||||
ynh_backup "/var/www/${app}" "sources"
|
|
||||||
|
|
||||||
### MySQL (remove if not used) ###
|
|
||||||
# If a MySQL database is used:
|
|
||||||
# # Dump the database
|
|
||||||
# dbname=$app
|
|
||||||
# dbuser=$app
|
|
||||||
# dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
|
|
||||||
# mysqldump -u "$dbuser" -p"$dbpass" --no-create-db "$dbname" > ./dump.sql
|
|
||||||
### MySQL end ###
|
|
||||||
|
|
||||||
# Copy NGINX configuration
|
|
||||||
domain=$(ynh_app_setting_get "$app" domain)
|
domain=$(ynh_app_setting_get "$app" domain)
|
||||||
ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "nginx.conf"
|
path=$(ynh_app_setting_get "$app" path)
|
||||||
|
with_mysql=$(ynh_app_setting_get "$app" with_mysql)
|
||||||
|
|
||||||
### PHP (remove if not used) ###
|
# Copy the app files
|
||||||
# If a dedicated php-fpm process is used:
|
DESTDIR="/var/www/${app}"
|
||||||
# # Copy PHP-FPM pool configuration
|
ynh_backup "$DESTDIR" "sources" 1
|
||||||
# ynh_backup "/etc/php5/fpm/pool.d/${app}.conf" "php-fpm.conf"
|
|
||||||
### PHP end ###
|
# Copy the conf files
|
||||||
|
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"
|
||||||
|
|
||||||
|
# Dump the database
|
||||||
|
if [[ $with_mysql -eq 1 ]]; then
|
||||||
|
dbname=$app
|
||||||
|
dbuser=$app
|
||||||
|
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
|
||||||
|
mysqldump -u "$dbuser" -p"$dbpass" --no-create-db "$dbname" > ./dump.sql
|
||||||
|
fi
|
||||||
|
|
153
scripts/install
153
scripts/install
|
@ -3,90 +3,103 @@
|
||||||
# Exit on command errors and treat unset variables as an error
|
# Exit on command errors and treat unset variables as an error
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
# This is a multi-instance app, meaning it can be installed several times independently
|
# Get instances specific variables
|
||||||
# The id of the app as stated in the manifest is available as $YNH_APP_ID
|
|
||||||
# The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...)
|
|
||||||
# The app instance name is available as $YNH_APP_INSTANCE_NAME
|
|
||||||
# - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample
|
|
||||||
# - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2
|
|
||||||
# - ynhexample__{N} for the subsequent installations, with N=3,4, ...
|
|
||||||
# The app instance name is probably what you are interested the most, since this is
|
|
||||||
# guaranteed to be unique. This is a good unique identifier to define installation path,
|
|
||||||
# db names, ...
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
|
||||||
# Retrieve arguments
|
# Retrieve arguments
|
||||||
domain=$YNH_APP_ARG_DOMAIN
|
domain=$1
|
||||||
path=$YNH_APP_ARG_PATH
|
path=${2%/}
|
||||||
admin=$YNH_APP_ARG_ADMIN
|
password=$3
|
||||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
is_public=$4
|
||||||
language=$YNH_APP_ARG_LANGUAGE
|
with_mysql=$5
|
||||||
|
|
||||||
# Source YunoHost helpers
|
# Source app helpers
|
||||||
source /usr/share/yunohost/helpers
|
. /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# Save app settings
|
|
||||||
ynh_app_setting_set "$app" admin "$admin"
|
|
||||||
ynh_app_setting_set "$app" is_public "$is_public"
|
|
||||||
ynh_app_setting_set "$app" language "$language"
|
|
||||||
|
|
||||||
# Check domain/path availability
|
# Check domain/path availability
|
||||||
sudo yunohost app checkurl "${domain}${path}" -a "$app" \
|
sudo yunohost app checkurl "${domain}${path}" -a "$app" \
|
||||||
|| ynh_die "Path not available: ${domain}${path}"
|
|| exit 1
|
||||||
|
|
||||||
# Copy source files
|
# Check password strength
|
||||||
src_path=/var/www/$app
|
[[ ${#password} -gt 5 ]] || ynh_die \
|
||||||
sudo mkdir -p $src_path
|
"The password is too weak, it must be longer than 5 characters"
|
||||||
sudo cp -a ../sources/. $src_path
|
|
||||||
|
|
||||||
# Set permissions to app files
|
# Check destination directory
|
||||||
# you may need to make some file and/or directory writeable by www-data (nginx user)
|
DESTDIR="/var/www/${app}"
|
||||||
sudo chown -R root: $src_path
|
[[ -d "$DESTDIR" ]] && ynh_die \
|
||||||
|
"The destination directory '${DESTDIR}' already exists.\
|
||||||
|
You should safely delete it before installing this app."
|
||||||
|
|
||||||
### MySQL (can be removed if not used) ###
|
# Save app settings
|
||||||
# If your app use a MySQL database you can use these lines to bootstrap
|
user="webapp${app_nb}"
|
||||||
# a database, an associated user and save the password in app settings.
|
ynh_app_setting_set "$app" is_public "$is_public"
|
||||||
#
|
ynh_app_setting_set "$app" with_mysql "$with_mysql"
|
||||||
# # Generate MySQL password and create database
|
ynh_app_setting_set "$app" password "$password"
|
||||||
# dbuser=$app
|
ynh_app_setting_set "$app" user "$user"
|
||||||
# dbname=$app
|
|
||||||
# dbpass=$(ynh_string_random 12)
|
|
||||||
# ynh_app_setting_set "$app" mysqlpwd "$dbpass"
|
|
||||||
# ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
|
|
||||||
#
|
|
||||||
# # Load initial SQL into the new database
|
|
||||||
# ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" \
|
|
||||||
# < "../sources/sql/mysql.init.sql"
|
|
||||||
### MySQL end ###
|
|
||||||
|
|
||||||
# Modify Nginx configuration file and copy it to Nginx conf directory
|
# Create the user account
|
||||||
nginx_conf=../conf/nginx.conf
|
sudo useradd -c "${app} user account" \
|
||||||
sed -i "s@YNH_WWW_PATH@$path@g" $nginx_conf
|
-d "$DESTDIR" -M -g www-data "$user" \
|
||||||
sed -i "s@YNH_WWW_ALIAS@$src_path/@g" $nginx_conf
|
|| ynh_die "Unable to create user account"
|
||||||
# If a dedicated php-fpm process is used:
|
sudo chpasswd <<< "${user}:${password}"
|
||||||
# Don't forget to modify ../conf/nginx.conf accordingly or your app will not work!
|
|
||||||
# sed -i "s@YNH_WWW_APP@$app@g" $nginx_conf
|
|
||||||
sudo cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf
|
|
||||||
|
|
||||||
### PHP (can be removed if not used) ###
|
# Harden SSH connection for the user
|
||||||
# If a dedicated php-fpm process is used:
|
echo "##-> ${app}
|
||||||
# Don't forget to modify ../conf/php-fpm.conf accordingly or your app will not work!
|
# Hardening user connection
|
||||||
#
|
Match User ${user}
|
||||||
# # Modify PHP-FPM pool configuration and copy it to the pool directory
|
ChrootDirectory %h
|
||||||
# sed -i "s@YNH_WWW_APP@$app@g" ../conf/php-fpm.conf
|
ForceCommand internal-sftp
|
||||||
# sed -i "s@YNH_WWW_ALIAS@$src_path/@g" ../conf/php-fpm.conf
|
AllowTcpForwarding no
|
||||||
# finalphpconf=/etc/php5/fpm/pool.d/$app.conf
|
PermitTunnel no
|
||||||
# sudo cp ../conf/php-fpm.conf $finalphpconf
|
X11Forwarding no
|
||||||
# sudo chown root: $finalphpconf
|
##<- ${app}" | sudo tee -a /etc/ssh/sshd_config >/dev/null
|
||||||
# sudo chmod 644 $finalphpconf
|
|
||||||
# sudo service php5-fpm reload
|
|
||||||
### PHP end ###
|
|
||||||
|
|
||||||
# If app is public, add url to SSOWat conf as skipped_uris
|
# Specify the user and the domain in the home page
|
||||||
if [[ $is_public -eq 1 ]]; then
|
sed -i "s@{DOMAIN}@${domain}@g" ../sources/www/index.html
|
||||||
# unprotected_uris allows SSO credentials to be passed anyway.
|
sed -i "s@{USER}@${user}@g" ../sources/www/index.html
|
||||||
ynh_app_setting_set "$app" unprotected_uris "/"
|
|
||||||
|
# Initialize database as needed
|
||||||
|
if [[ $with_mysql -eq 1 ]]; then
|
||||||
|
dbname=$app
|
||||||
|
dbuser=$app
|
||||||
|
dbpass=$(ynh_string_random)
|
||||||
|
ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
|
||||||
|
|
||||||
|
# Store the database access
|
||||||
|
echo -e "# MySQL Database
|
||||||
|
name: ${dbname}\nuser: ${dbuser}\npass: ${dbpass}" > ../sources/db_access.txt
|
||||||
|
ynh_app_setting_set "$app" mysqlpwd "$dbpass"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Copy files to the right place and set permissions
|
||||||
|
sudo cp -r ../sources "$DESTDIR"
|
||||||
|
sudo chown -hR "${user}:" "$DESTDIR"
|
||||||
|
|
||||||
|
# Home directory of the user need to be owned by root to allow
|
||||||
|
# SFTP connections
|
||||||
|
sudo chown root: "$DESTDIR"
|
||||||
|
|
||||||
|
# Set SSOwat rules
|
||||||
|
[[ $is_public -eq 1 ]] \
|
||||||
|
&& ynh_app_setting_set "$app" skipped_uris "/"
|
||||||
|
|
||||||
|
# Copy and set nginx configuration
|
||||||
|
nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.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
|
||||||
|
sed -i "s@{POOLNAME}@${app}@g" ../conf/nginx.conf
|
||||||
|
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}@${user}@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"
|
||||||
|
|
||||||
# Reload services
|
# Reload services
|
||||||
|
sudo service php5-fpm reload
|
||||||
sudo service nginx reload
|
sudo service nginx reload
|
||||||
|
sudo service sshd reload
|
||||||
|
|
|
@ -1,34 +1,40 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# See comments in install script
|
# Get multi-instances specific variables
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
app_nb=$YNH_APP_INSTANCE_NUMBER
|
||||||
|
|
||||||
# Source YunoHost helpers
|
# Source app helpers
|
||||||
source /usr/share/yunohost/helpers
|
. /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# Retrieve app settings
|
# Retrieve app settings
|
||||||
domain=$(ynh_app_setting_get "$app" domain)
|
domain=$(ynh_app_setting_get "$app" domain)
|
||||||
|
with_mysql=$(ynh_app_setting_get "$app" with_mysql)
|
||||||
|
user=$(ynh_app_setting_get "$app" user)
|
||||||
|
|
||||||
# Remove sources
|
# Drop MySQL database and user as needed
|
||||||
sudo rm -rf /var/www/$app
|
if [[ $with_mysql -eq 1 ]]; then
|
||||||
|
dbname=$app
|
||||||
|
dbuser=$app
|
||||||
|
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
|
||||||
|
ynh_mysql_drop_db $dbname || true
|
||||||
|
ynh_mysql_drop_user $dbuser || true
|
||||||
|
fi
|
||||||
|
|
||||||
# Remove nginx configuration file
|
# Delete app directory and configurations
|
||||||
sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf
|
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"
|
||||||
|
|
||||||
### PHP (remove if not used) ###
|
# Remove custom SSH configuration
|
||||||
# If a dedicated php-fpm process is used:
|
sudo sed -i "/##-> ${app}/,/##<- ${app}/d" /etc/ssh/sshd_config
|
||||||
# sudo rm -f /etc/php5/fpm/pool.d/$app.conf
|
|
||||||
# sudo service php5-fpm reload
|
|
||||||
### PHP end ###
|
|
||||||
|
|
||||||
### MySQL (remove if not used) ###
|
# Reload services
|
||||||
# If a MySQL database is used:
|
sudo service php5-fpm restart || true
|
||||||
# # Drop MySQL database and user
|
sudo service nginx reload || true
|
||||||
# dbname=$app
|
sudo service sshd reload
|
||||||
# dbuser=$app
|
|
||||||
# ynh_mysql_drop_db "$dbname" || true
|
|
||||||
# ynh_mysql_drop_user "$dbuser" || true
|
|
||||||
### MySQL end ###
|
|
||||||
|
|
||||||
# Reload nginx service
|
# Remove the user account
|
||||||
sudo service nginx reload
|
id "$user" >/dev/null 2>&1 \
|
||||||
|
&& sudo deluser --quiet --force "$user" >/dev/null \
|
||||||
|
|| true
|
||||||
|
|
|
@ -1,52 +1,81 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Note: each files and directories you've saved using the ynh_backup helper
|
set -e
|
||||||
# will be located in the current directory, regarding the last argument.
|
|
||||||
|
|
||||||
# Exit on command errors and treat unset variables as an error
|
# Get multi-instances specific variables
|
||||||
set -eu
|
|
||||||
|
|
||||||
# See comments in install script
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
# Source YunoHost helpers
|
# Source app helpers
|
||||||
source /usr/share/yunohost/helpers
|
. /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# Retrieve old app settings
|
# Retrieve old app settings
|
||||||
domain=$(ynh_app_setting_get "$app" domain)
|
domain=$(ynh_app_setting_get "$app" domain)
|
||||||
path=$(ynh_app_setting_get "$app" path)
|
path=$(ynh_app_setting_get "$app" path)
|
||||||
|
with_mysql=$(ynh_app_setting_get "$app" with_mysql)
|
||||||
|
password=$(ynh_app_setting_get "$app" password)
|
||||||
|
user=$(ynh_app_setting_get "$app" user)
|
||||||
|
|
||||||
# Check domain/path availability
|
# Check domain/path availability
|
||||||
sudo yunohost app checkurl "${domain}${path}" -a "$app" \
|
sudo yunohost app checkurl "${domain}${path}" -a "$app" \
|
||||||
|| ynh_die "Path not available: ${domain}${path}"
|
|| exit 1
|
||||||
|
|
||||||
# Restore sources & data
|
# Check destination directory
|
||||||
src_path="/var/www/${app}"
|
DESTDIR="/var/www/$app"
|
||||||
sudo cp -a ./sources "$src_path"
|
[[ -d $DESTDIR ]] && ynh_die \
|
||||||
|
"The destination directory '$DESTDIR' already exists.\
|
||||||
|
You should safely delete it before restoring this app."
|
||||||
|
|
||||||
# Restore permissions to app files
|
# Check configuration files
|
||||||
# you may need to make some file and/or directory writeable by www-data (nginx user)
|
nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
||||||
sudo chown -R root: "$src_path"
|
[[ -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."
|
||||||
|
|
||||||
### MySQL (remove if not used) ###
|
# Create the user account
|
||||||
# If a MySQL database is used:
|
sudo useradd -c "${app} user account" \
|
||||||
# # Create and restore the database
|
-d "$DESTDIR" -M -g www-data "$user" \
|
||||||
# dbname=$app
|
|| ynh_die "Unable to create user account"
|
||||||
# dbuser=$app
|
sudo chpasswd <<< "${user}:${password}"
|
||||||
# dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
|
|
||||||
# ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
|
|
||||||
# ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ./dump.sql
|
|
||||||
### MySQL end ###
|
|
||||||
|
|
||||||
# Restore NGINX configuration
|
# Harden SSH connection for the user
|
||||||
sudo cp -a ./nginx.conf "/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
echo "##-> ${app}
|
||||||
|
# Hardening user connection
|
||||||
|
Match User ${user}
|
||||||
|
ChrootDirectory %h
|
||||||
|
ForceCommand internal-sftp
|
||||||
|
AllowTcpForwarding no
|
||||||
|
PermitTunnel no
|
||||||
|
X11Forwarding no
|
||||||
|
##<- ${app}" | sudo tee -a /etc/ssh/sshd_config >/dev/null
|
||||||
|
|
||||||
### PHP (remove if not used) ###
|
# Restore the app files
|
||||||
# If a dedicated php-fpm process is used:
|
sudo cp -a ./sources "$DESTDIR"
|
||||||
# # Copy PHP-FPM pool configuration and reload the service
|
sudo chown -hR "${user}:" "$DESTDIR"
|
||||||
# sudo cp -a ./php-fpm.conf "/etc/php5/fpm/pool.d/${app}.conf"
|
|
||||||
# sudo service php5-fpm reload
|
|
||||||
### PHP end ###
|
|
||||||
|
|
||||||
# Restart webserver
|
# Home directory of the user need to be owned by root to allow
|
||||||
sudo service nginx reload
|
# SFTP connections
|
||||||
|
sudo chown root: "$DESTDIR"
|
||||||
|
|
||||||
|
# Create and restore the database as needed
|
||||||
|
if [[ $with_mysql -eq 1 ]]; then
|
||||||
|
dbname=$app
|
||||||
|
dbuser=$app
|
||||||
|
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
|
||||||
|
ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
|
||||||
|
[[ -f ./dump.sql ]] \
|
||||||
|
&& ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ./dump.sql \
|
||||||
|
|| echo "No MySQL dump has been found" >&2
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Restore configuration files
|
||||||
|
sudo cp -a ./conf/nginx.conf "$nginx_conf"
|
||||||
|
sudo cp -a ./conf/php-fpm.conf "$phpfpm_conf"
|
||||||
|
|
||||||
|
# Reload services
|
||||||
|
sudo service php5-fpm reload || true
|
||||||
|
sudo service nginx reload || true
|
||||||
|
sudo service sshd reload
|
||||||
|
|
|
@ -1,59 +1,53 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Exit on command errors and treat unset variables as an error
|
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
# See comments in install script
|
# Get multi-instances specific variables
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
# Source YunoHost helpers
|
# Source app helpers
|
||||||
source /usr/share/yunohost/helpers
|
. /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# Retrieve app settings
|
# Retrieve app settings
|
||||||
domain=$(ynh_app_setting_get "$app" domain)
|
domain=$(ynh_app_setting_get "$app" domain)
|
||||||
path=$(ynh_app_setting_get "$app" path)
|
path=$(ynh_app_setting_get "$app" path)
|
||||||
admin=$(ynh_app_setting_get "$app" admin)
|
|
||||||
is_public=$(ynh_app_setting_get "$app" is_public)
|
|
||||||
language=$(ynh_app_setting_get "$app" language)
|
|
||||||
|
|
||||||
# Remove trailing "/" for next commands
|
|
||||||
path=${path%/}
|
path=${path%/}
|
||||||
|
is_public=$(ynh_app_setting_get "$app" is_public)
|
||||||
|
with_mysql=$(ynh_app_setting_get "$app" with_mysql)
|
||||||
|
password=$(ynh_app_setting_get "$app" password)
|
||||||
|
user=$(ynh_app_setting_get "$app" user)
|
||||||
|
|
||||||
# Copy source files
|
([[ -n "$with_mysql" ]] && [[ -n "$password" ]] && [[ -n "$user" ]]) \
|
||||||
src_path=/var/www/$app
|
|| ynh_die "The app changed and can not be automatically upgraded. \
|
||||||
sudo mkdir -p $src_path
|
You will have to manually upgrade it following those instructions: \
|
||||||
sudo cp -a ../sources/. $src_path
|
https://github.com/garwinch/Yuno_app_cagette#upgrade"
|
||||||
|
|
||||||
# Set permissions to app files
|
# Check destination directory
|
||||||
# you may need to make some file and/or directory writeable by www-data (nginx user)
|
DESTDIR="/var/www/$app"
|
||||||
sudo chown -R root: $src_path
|
[[ ! -d $DESTDIR ]] && ynh_die \
|
||||||
|
"The destination directory '$DESTDIR' does not exist.\
|
||||||
|
The app is not correctly installed, you should remove it first."
|
||||||
|
|
||||||
# Modify Nginx configuration file and copy it to Nginx conf directory
|
# Harden SSH connection for the user
|
||||||
nginx_conf=../conf/nginx.conf
|
sudo sed -i "/##-> ${app}/,/##<- ${app}/d" /etc/ssh/sshd_config
|
||||||
sed -i "s@YNH_WWW_PATH@$path@g" $nginx_conf
|
echo "##-> ${app}
|
||||||
sed -i "s@YNH_WWW_ALIAS@$src_path/@g" $nginx_conf
|
# Hardening user connection
|
||||||
# If a dedicated php-fpm process is used:
|
Match User ${user}
|
||||||
#
|
ChrootDirectory %h
|
||||||
# sed -i "s@YNH_WWW_APP@$app@g" $nginx_conf
|
ForceCommand internal-sftp
|
||||||
sudo cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf
|
AllowTcpForwarding no
|
||||||
|
PermitTunnel no
|
||||||
|
X11Forwarding no
|
||||||
|
##<- ${app}" | sudo tee -a /etc/ssh/sshd_config >/dev/null
|
||||||
|
|
||||||
### PHP (remove if not used) ###
|
# Fix permissions
|
||||||
# If a dedicated php-fpm process is used:
|
sudo chown -hR "${user}:" "$DESTDIR"
|
||||||
# # Modify PHP-FPM pool configuration and copy it to the pool directory
|
|
||||||
# sed -i "s@YNH_WWW_APP@$app@g" ../conf/php-fpm.conf
|
|
||||||
# sed -i "s@YNH_WWW_ALIAS@$src_path/@g" ../conf/php-fpm.conf
|
|
||||||
# finalphpconf=/etc/php5/fpm/pool.d/$app.conf
|
|
||||||
# sudo cp ../conf/php-fpm.conf $finalphpconf
|
|
||||||
# sudo chown root: $finalphpconf
|
|
||||||
# sudo chmod 644 $finalphpconf
|
|
||||||
# sudo service php5-fpm restart
|
|
||||||
### PHP end ###
|
|
||||||
|
|
||||||
# If app is public, add url to SSOWat conf as skipped_uris
|
# Home directory of the user need to be owned by root to allow
|
||||||
if [[ $is_public -eq 1 ]]; then
|
# SFTP connections
|
||||||
# See install script
|
sudo chown root: "$DESTDIR"
|
||||||
ynh_app_setting_set "$app" unprotected_uris "/"
|
|
||||||
fi
|
# Set SSOwat rules
|
||||||
|
[[ $is_public -eq 1 ]] \
|
||||||
|
&& ynh_app_setting_set "$app" skipped_uris "/"
|
||||||
|
|
||||||
# Reload nginx service
|
|
||||||
sudo service nginx reload
|
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
Place the sources of the webapp in this folder.
|
The sources of the webapp are based on
|
||||||
|
|
||||||
This file can be removed.
|
https://github.com/bablukid/cagette
|
||||||
|
|
1
sources/cagette-php/lang/fr/tmp/vendor__view.mtt.php
Normal file
1
sources/cagette-php/lang/fr/tmp/vendor__view.mtt.php
Normal file
|
@ -0,0 +1 @@
|
||||||
|
test files
|
28
sources/config.xml.dist
Normal file
28
sources/config.xml.dist
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
<config
|
||||||
|
lang="fr"
|
||||||
|
langs="fr"
|
||||||
|
|
||||||
|
host="app.cagette"
|
||||||
|
name = "Cagette.net"
|
||||||
|
default_email = "noreply@cagette.net"
|
||||||
|
webmaster_email = "mon_email@mon_domaine.fr"
|
||||||
|
|
||||||
|
database="mysql://root:root@localhost/cagette"
|
||||||
|
sqllog="0"
|
||||||
|
|
||||||
|
debug="0"
|
||||||
|
cache="1"
|
||||||
|
maintain="0"
|
||||||
|
cachetpl="0"
|
||||||
|
key="carotteMagique"
|
||||||
|
|
||||||
|
smtp_host="smtp.mandrillapp.com"
|
||||||
|
smtp_port="587"
|
||||||
|
smtp_user="mon_email@mon_domaine.fr"
|
||||||
|
smtp_pass="blabla"
|
||||||
|
|
||||||
|
mt.net.form.Form.HTML5 = "1"
|
||||||
|
mt.net.form.Form.USE_TWITTER_BOOTSTRAP = "1"
|
||||||
|
|
||||||
|
google_geocoding_key="blabla"
|
||||||
|
/>
|
Loading…
Add table
Reference in a new issue