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
|
||||
- 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.
|
||||
##Premiers pas
|
||||
|
||||
**More information on the documentation page:**
|
||||
https://yunohost.org/packaging_apps
|
||||
- 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
|
||||
|
|
|
@ -1,33 +1,48 @@
|
|||
location YNH_WWW_PATH {
|
||||
location / {
|
||||
alias /var/www/cagette_app/www/;
|
||||
|
||||
# Path to source
|
||||
alias YNH_WWW_ALIAS ;
|
||||
# Default indexes and catch-all
|
||||
index index.html index.php;
|
||||
try_files $uri $uri/ /index.php?$args;
|
||||
|
||||
# Example PHP configuration (remove if not used)
|
||||
index index.php;
|
||||
# Prevent useless logs
|
||||
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
|
||||
#client_max_body_size 50M;
|
||||
# Deny access to hidden files and directories
|
||||
location ~ ^/(.+/|)\.(?!well-known\/) {
|
||||
deny all;
|
||||
}
|
||||
|
||||
try_files $uri $uri/ index.php;
|
||||
location ~ [^/]\.php(/|$) {
|
||||
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
||||
fastcgi_pass unix:/var/run/php5-fpm.sock;
|
||||
|
||||
# Filename to be changed if dedicated php-fpm process is required
|
||||
# This is to be used INSTEAD of line above
|
||||
# Don't forget to adjust scripts install/upgrade/remove/backup accordingly
|
||||
#
|
||||
#fastcgi_pass unix:/var/run/php5-fpm-YNH_WWW_APP.sock;
|
||||
# Execute and serve PHP files
|
||||
location ~ [^/]\.php(/|$) {
|
||||
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
||||
fastcgi_pass unix:/var/run/php5-fpm-my_webapp__2.sock;
|
||||
fastcgi_index index.php;
|
||||
include fastcgi_params;
|
||||
fastcgi_param REMOTE_USER $remote_user;
|
||||
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||
fastcgi_param SCRIPT_FILENAME $request_filename;
|
||||
}
|
||||
|
||||
fastcgi_index index.php;
|
||||
include fastcgi_params;
|
||||
fastcgi_param REMOTE_USER $remote_user;
|
||||
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||
fastcgi_param SCRIPT_FILENAME $request_filename;
|
||||
}
|
||||
# PHP configuration end
|
||||
# Include SSOWAT user panel.
|
||||
include conf.d/yunohost_panel.conf.inc;
|
||||
|
||||
location ~ \.(png|gif|jpg|ico|swf|css|js|dat)$ {
|
||||
}
|
||||
|
||||
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",
|
||||
"id": "ynhexample",
|
||||
"name": "cagette_app",
|
||||
"id": "cagette",
|
||||
"packaging_format": 1,
|
||||
"description": {
|
||||
"en": "Example package for YunoHost application.",
|
||||
"fr": "Exemple de package d’application pour YunoHost."
|
||||
"en": "Package for Cagette.net application in YunoHost.",
|
||||
"fr": "Package pour l’application Cagette.net pour YunoHost."
|
||||
},
|
||||
"url": "https://example.com",
|
||||
"url": "http://www.cagette.net",
|
||||
"license": "free",
|
||||
"maintainer": {
|
||||
"name": "John doe",
|
||||
"email": "john.doe@example.com",
|
||||
"url": "http://example.com"
|
||||
"name": "Forissier Gaspard",
|
||||
"email": "gaspard@garwinch.ddns.net",
|
||||
"url": "https://garwinch.ddns.net"
|
||||
},
|
||||
"requirements": {
|
||||
"yunohost": ">> 2.4.0"
|
||||
|
@ -28,20 +28,16 @@
|
|||
"name": "domain",
|
||||
"type": "domain",
|
||||
"ask": {
|
||||
"en": "Choose a domain name for ynhexample",
|
||||
"fr": "Choisissez un nom de domaine pour ynhexample"
|
||||
"en": "Choose a domain name for cagette_app",
|
||||
"fr": "Choisissez un nom de domaine pour cagette_app"
|
||||
},
|
||||
"example": "example.com"
|
||||
},
|
||||
{
|
||||
"name": "path",
|
||||
"type": "path",
|
||||
"ask": {
|
||||
"en": "Choose a path for ynhexample",
|
||||
"fr": "Choisissez un chemin pour ynhexample"
|
||||
},
|
||||
"example": "/example",
|
||||
"default": "/example"
|
||||
|
||||
"default": "/"
|
||||
},
|
||||
{
|
||||
"name": "admin",
|
||||
|
|
|
@ -3,31 +3,29 @@
|
|||
# Exit on command errors and treat unset variables as an error
|
||||
set -eu
|
||||
|
||||
# See comments in install script
|
||||
# Get multi-instances specific variables
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Source YunoHost helpers
|
||||
source /usr/share/yunohost/helpers
|
||||
# Source app helpers
|
||||
. /usr/share/yunohost/helpers
|
||||
|
||||
# Backup sources & data
|
||||
# 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
|
||||
# Retrieve app settings
|
||||
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) ###
|
||||
# If a dedicated php-fpm process is used:
|
||||
# # Copy PHP-FPM pool configuration
|
||||
# ynh_backup "/etc/php5/fpm/pool.d/${app}.conf" "php-fpm.conf"
|
||||
### PHP end ###
|
||||
# Copy the app files
|
||||
DESTDIR="/var/www/${app}"
|
||||
ynh_backup "$DESTDIR" "sources" 1
|
||||
|
||||
# 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
|
||||
set -eu
|
||||
|
||||
# This is a multi-instance app, meaning it can be installed several times independently
|
||||
# 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, ...
|
||||
# Get instances specific variables
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
|
||||
# Retrieve arguments
|
||||
domain=$YNH_APP_ARG_DOMAIN
|
||||
path=$YNH_APP_ARG_PATH
|
||||
admin=$YNH_APP_ARG_ADMIN
|
||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||
language=$YNH_APP_ARG_LANGUAGE
|
||||
domain=$1
|
||||
path=${2%/}
|
||||
password=$3
|
||||
is_public=$4
|
||||
with_mysql=$5
|
||||
|
||||
# Source YunoHost helpers
|
||||
source /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"
|
||||
# Source app helpers
|
||||
. /usr/share/yunohost/helpers
|
||||
|
||||
# Check domain/path availability
|
||||
sudo yunohost app checkurl "${domain}${path}" -a "$app" \
|
||||
|| ynh_die "Path not available: ${domain}${path}"
|
||||
|| exit 1
|
||||
|
||||
# Copy source files
|
||||
src_path=/var/www/$app
|
||||
sudo mkdir -p $src_path
|
||||
sudo cp -a ../sources/. $src_path
|
||||
# Check password strength
|
||||
[[ ${#password} -gt 5 ]] || ynh_die \
|
||||
"The password is too weak, it must be longer than 5 characters"
|
||||
|
||||
# Set permissions to app files
|
||||
# you may need to make some file and/or directory writeable by www-data (nginx user)
|
||||
sudo chown -R root: $src_path
|
||||
# Check destination directory
|
||||
DESTDIR="/var/www/${app}"
|
||||
[[ -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) ###
|
||||
# If your app use a MySQL database you can use these lines to bootstrap
|
||||
# a database, an associated user and save the password in app settings.
|
||||
#
|
||||
# # Generate MySQL password and create database
|
||||
# dbuser=$app
|
||||
# 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 ###
|
||||
# Save app settings
|
||||
user="webapp${app_nb}"
|
||||
ynh_app_setting_set "$app" is_public "$is_public"
|
||||
ynh_app_setting_set "$app" with_mysql "$with_mysql"
|
||||
ynh_app_setting_set "$app" password "$password"
|
||||
ynh_app_setting_set "$app" user "$user"
|
||||
|
||||
# Modify Nginx configuration file and copy it to Nginx conf directory
|
||||
nginx_conf=../conf/nginx.conf
|
||||
sed -i "s@YNH_WWW_PATH@$path@g" $nginx_conf
|
||||
sed -i "s@YNH_WWW_ALIAS@$src_path/@g" $nginx_conf
|
||||
# If a dedicated php-fpm process is used:
|
||||
# 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
|
||||
# Create the user account
|
||||
sudo useradd -c "${app} user account" \
|
||||
-d "$DESTDIR" -M -g www-data "$user" \
|
||||
|| ynh_die "Unable to create user account"
|
||||
sudo chpasswd <<< "${user}:${password}"
|
||||
|
||||
### PHP (can be removed if not used) ###
|
||||
# If a dedicated php-fpm process is used:
|
||||
# Don't forget to modify ../conf/php-fpm.conf accordingly or your app will not work!
|
||||
#
|
||||
# # 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 reload
|
||||
### PHP end ###
|
||||
# Harden SSH connection for the user
|
||||
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
|
||||
|
||||
# If app is public, add url to SSOWat conf as skipped_uris
|
||||
if [[ $is_public -eq 1 ]]; then
|
||||
# unprotected_uris allows SSO credentials to be passed anyway.
|
||||
ynh_app_setting_set "$app" unprotected_uris "/"
|
||||
# Specify the user and the domain in the home page
|
||||
sed -i "s@{DOMAIN}@${domain}@g" ../sources/www/index.html
|
||||
sed -i "s@{USER}@${user}@g" ../sources/www/index.html
|
||||
|
||||
# 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
|
||||
|
||||
# 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
|
||||
sudo service php5-fpm reload
|
||||
sudo service nginx reload
|
||||
sudo service sshd reload
|
||||
|
|
|
@ -1,34 +1,40 @@
|
|||
#!/bin/bash
|
||||
|
||||
# See comments in install script
|
||||
# Get multi-instances specific variables
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
app_nb=$YNH_APP_INSTANCE_NUMBER
|
||||
|
||||
# Source YunoHost helpers
|
||||
source /usr/share/yunohost/helpers
|
||||
# Source app helpers
|
||||
. /usr/share/yunohost/helpers
|
||||
|
||||
# Retrieve app settings
|
||||
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
|
||||
sudo rm -rf /var/www/$app
|
||||
# Drop MySQL database and user as needed
|
||||
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
|
||||
sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf
|
||||
# Delete app directory and configurations
|
||||
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) ###
|
||||
# If a dedicated php-fpm process is used:
|
||||
# sudo rm -f /etc/php5/fpm/pool.d/$app.conf
|
||||
# sudo service php5-fpm reload
|
||||
### PHP end ###
|
||||
# Remove custom SSH configuration
|
||||
sudo sed -i "/##-> ${app}/,/##<- ${app}/d" /etc/ssh/sshd_config
|
||||
|
||||
### MySQL (remove if not used) ###
|
||||
# If a MySQL database is used:
|
||||
# # Drop MySQL database and user
|
||||
# dbname=$app
|
||||
# dbuser=$app
|
||||
# ynh_mysql_drop_db "$dbname" || true
|
||||
# ynh_mysql_drop_user "$dbuser" || true
|
||||
### MySQL end ###
|
||||
# Reload services
|
||||
sudo service php5-fpm restart || true
|
||||
sudo service nginx reload || true
|
||||
sudo service sshd reload
|
||||
|
||||
# Reload nginx service
|
||||
sudo service nginx reload
|
||||
# Remove the user account
|
||||
id "$user" >/dev/null 2>&1 \
|
||||
&& sudo deluser --quiet --force "$user" >/dev/null \
|
||||
|| true
|
||||
|
|
|
@ -1,52 +1,81 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Note: each files and directories you've saved using the ynh_backup helper
|
||||
# will be located in the current directory, regarding the last argument.
|
||||
set -e
|
||||
|
||||
# Exit on command errors and treat unset variables as an error
|
||||
set -eu
|
||||
|
||||
# See comments in install script
|
||||
# Get multi-instances specific variables
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Source YunoHost helpers
|
||||
source /usr/share/yunohost/helpers
|
||||
# Source app helpers
|
||||
. /usr/share/yunohost/helpers
|
||||
|
||||
# Retrieve old app settings
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
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
|
||||
sudo yunohost app checkurl "${domain}${path}" -a "$app" \
|
||||
|| ynh_die "Path not available: ${domain}${path}"
|
||||
|| exit 1
|
||||
|
||||
# Restore sources & data
|
||||
src_path="/var/www/${app}"
|
||||
sudo cp -a ./sources "$src_path"
|
||||
# Check destination directory
|
||||
DESTDIR="/var/www/$app"
|
||||
[[ -d $DESTDIR ]] && ynh_die \
|
||||
"The destination directory '$DESTDIR' already exists.\
|
||||
You should safely delete it before restoring this app."
|
||||
|
||||
# Restore permissions to app files
|
||||
# you may need to make some file and/or directory writeable by www-data (nginx user)
|
||||
sudo chown -R root: "$src_path"
|
||||
# Check configuration files
|
||||
nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
||||
[[ -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) ###
|
||||
# If a MySQL database is used:
|
||||
# # Create and restore the database
|
||||
# dbname=$app
|
||||
# dbuser=$app
|
||||
# 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 ###
|
||||
# Create the user account
|
||||
sudo useradd -c "${app} user account" \
|
||||
-d "$DESTDIR" -M -g www-data "$user" \
|
||||
|| ynh_die "Unable to create user account"
|
||||
sudo chpasswd <<< "${user}:${password}"
|
||||
|
||||
# Restore NGINX configuration
|
||||
sudo cp -a ./nginx.conf "/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
||||
# Harden SSH connection for the user
|
||||
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) ###
|
||||
# If a dedicated php-fpm process is used:
|
||||
# # Copy PHP-FPM pool configuration and reload the service
|
||||
# sudo cp -a ./php-fpm.conf "/etc/php5/fpm/pool.d/${app}.conf"
|
||||
# sudo service php5-fpm reload
|
||||
### PHP end ###
|
||||
# Restore the app files
|
||||
sudo cp -a ./sources "$DESTDIR"
|
||||
sudo chown -hR "${user}:" "$DESTDIR"
|
||||
|
||||
# Restart webserver
|
||||
sudo service nginx reload
|
||||
# Home directory of the user need to be owned by root to allow
|
||||
# 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
|
||||
|
||||
# Exit on command errors and treat unset variables as an error
|
||||
set -eu
|
||||
|
||||
# See comments in install script
|
||||
# Get multi-instances specific variables
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
# Source YunoHost helpers
|
||||
source /usr/share/yunohost/helpers
|
||||
# Source app helpers
|
||||
. /usr/share/yunohost/helpers
|
||||
|
||||
# Retrieve app settings
|
||||
domain=$(ynh_app_setting_get "$app" domain)
|
||||
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%/}
|
||||
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
|
||||
src_path=/var/www/$app
|
||||
sudo mkdir -p $src_path
|
||||
sudo cp -a ../sources/. $src_path
|
||||
([[ -n "$with_mysql" ]] && [[ -n "$password" ]] && [[ -n "$user" ]]) \
|
||||
|| ynh_die "The app changed and can not be automatically upgraded. \
|
||||
You will have to manually upgrade it following those instructions: \
|
||||
https://github.com/garwinch/Yuno_app_cagette#upgrade"
|
||||
|
||||
# Set permissions to app files
|
||||
# you may need to make some file and/or directory writeable by www-data (nginx user)
|
||||
sudo chown -R root: $src_path
|
||||
# Check destination directory
|
||||
DESTDIR="/var/www/$app"
|
||||
[[ ! -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
|
||||
nginx_conf=../conf/nginx.conf
|
||||
sed -i "s@YNH_WWW_PATH@$path@g" $nginx_conf
|
||||
sed -i "s@YNH_WWW_ALIAS@$src_path/@g" $nginx_conf
|
||||
# If a dedicated php-fpm process is used:
|
||||
#
|
||||
# sed -i "s@YNH_WWW_APP@$app@g" $nginx_conf
|
||||
sudo cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf
|
||||
# Harden SSH connection for the user
|
||||
sudo sed -i "/##-> ${app}/,/##<- ${app}/d" /etc/ssh/sshd_config
|
||||
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) ###
|
||||
# If a dedicated php-fpm process is used:
|
||||
# # 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 ###
|
||||
# Fix permissions
|
||||
sudo chown -hR "${user}:" "$DESTDIR"
|
||||
|
||||
# If app is public, add url to SSOWat conf as skipped_uris
|
||||
if [[ $is_public -eq 1 ]]; then
|
||||
# See install script
|
||||
ynh_app_setting_set "$app" unprotected_uris "/"
|
||||
fi
|
||||
# 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 "/"
|
||||
|
||||
# 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