1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/framagames_ynh.git synced 2024-09-03 18:36:28 +02:00

Initial commit

This commit is contained in:
polytan02 2015-04-11 14:44:40 +01:00
parent 9c8c5af202
commit cc29309df5
7 changed files with 238 additions and 2 deletions

View file

@ -1,2 +1,4 @@
# webapp_multi_ynh
multi instances webapp for yunohost
Multi Instances Web App
-------------------
No FTP Support

20
conf/nginx.conf Normal file
View file

@ -0,0 +1,20 @@
location PATHTOCHANGE {
alias ALIASTOCHANGE;
if ($scheme = http) {
rewrite ^ https://$server_name$request_uri? permanent;
}
index index.php index.html index.htm;
default_type text/html;
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;
}

51
manifest.json Normal file
View file

@ -0,0 +1,51 @@
{
"name": "Multi Instances Webapp",
"id": "webapp_multi",
"description": {
"en": "Multi Instances Web App without FTP access",
"fr": "Multi Instances Web App vide sans accès FTP"
},
"maintainer": {
"name": "Polytan02",
"email": "polytan02@mcgva.org"
},
"multi_instance": "true",
"arguments": {
"install" : [
{
"name": "domain",
"ask": {
"en": "Choose a domain for your Webapp",
"fr": "Choisissez un domaine pour votre Webapp"
},
"example": "domain.org"
},
{
"name": "path",
"ask": {
"en": "Choose a path for your Webapp",
"fr": "Choisissez un chemin pour votre Webapp"
},
"example": "/site",
"default": "/site"
},
{
"name": "admin",
"ask": {
"en": "Choose the YunoHost user",
"fr": "Choisissez l'utilisateur YunoHost associé"
},
"example": "johndoe"
},
{
"name": "is_public",
"ask": {
"en": "Is it a public website ?",
"fr": "Est-ce un site public ?"
},
"choices": ["Yes", "No"],
"default": "Yes"
}
]
}
}

96
scripts/install Normal file
View file

@ -0,0 +1,96 @@
#!/bin/bash
# Retrieve arguments
domain=$1
path=$2
user=$3
is_public=$4
# sitename == path without "/"
sitename=$(echo $path | cut -d '/' -f 2)
if [ $path = "/" ]
then
sitename="root"
fi
app=webapp_multi_$domain_$sitename
final_path=/var/www/$app_$domain_$sitename
# Check domain/path availability
sudo yunohost app checkurl $domain$path -a $app
if [[ ! $? -eq 0 ]]; then
exit 1
fi
# Check user
sudo yunohost user list --json | grep -q "\"username\": \"$user\""
if [[ ! $? -eq 0 ]]; then
echo "Wrong user"
exit 1
fi
sudo yunohost app setting $app user -v $user
#sudo yunohost app setting $app ftp_user -v $user
# Créer le dossier parent des webapp pour l'utilisateur
#if test ! -d $parent_dir
#then # Créer le dossier parent uniquement si il n'existe pas
# Creation of folder
sudo rm -rf $final_path
sudo mkdir $final_path
# Base site
sudo cp ../sources/index.html $final_path/
# Set permissions
sudo chmod 775 -R $final_path
sudo chown -hR www-data:www-data $final_path
#else
# echo "Création du dossier $parent_dir ignorée, le dossier existe déjà."
#fi
# Change user ID in configurations
#sed -i "s@FTPUSER@$user@g" ../sources/index_ftp.html
#sed -i "s@HOST@$domain@g" ../sources/index_ftp.html
#sed -i "s@NET2FTP@$netftp_path@g" ../sources/index_ftp.html
# Copy files to the right place
#sudo mkdir $final_path
#sudo cp ../sources/index.html $final_path/
# Vérifie si pure-ftpd est déjà installé
#if test -f /usr/sbin/pure-ftpd-ldap
#then # Si oui, vérifie si net2ftp est également installé.
# if test -d $parent_dir/netftp
# then
# sudo cp ../sources/index_ftp.html $final_path/index.html # Remplace l'index.html par celui intégrant les informations ftp
# fi
#fi
# Set permissions
#sudo chmod 775 -R $final_path
#sudo chown -hR $user:www-data $final_path
# Modify Nginx configuration file and copy it to Nginx conf directory
sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf
sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$sitename.conf
# Make app public if necessary
sudo yunohost app setting $app is_public -v "$is_public"
if [ "$is_public" = "Yes" ];
then
sudo yunohost app setting $app skipped_uris -v "$domain$path"
fi
# Reload Nginx and regenerate SSOwat conf
sudo service nginx reload
sudo yunohost app ssowatconf

22
scripts/remove Normal file
View file

@ -0,0 +1,22 @@
#!/bin/bash
user=$(sudo yunohost app setting my_webapp user)
path=$(sudo yunohost app setting my_webapp path)
domain=$(sudo yunohost app setting my_webapp domain)
parent_dir=/var/www/webapp_$user
name=$(echo $path | cut -d '/' -f 2)
final_path=$parent_dir$path
# Suppression du dossier de la webapp
sudo rm -rf $final_path
# Suppression de la config nginx de la webapp
sudo rm -f /etc/nginx/conf.d/$domain.d/$name.conf
# Vérifie si le dossier parent est vide. Ce qui signifie que toutes les webapp ont été désinstallées. Ainsi que le client ftp net2ftp.
if test -z "$(ls $parent_dir | head -n1)"
then
sudo rmdir $parent_dir
fi
sudo service nginx reload
sudo yunohost app ssowatconf

29
scripts/upgrade Normal file
View file

@ -0,0 +1,29 @@
#!/bin/bash
# Retrieve arguments
domain=$(sudo yunohost app setting my_webapp domain)
path=$(sudo yunohost app setting my_webapp path)
user=$(sudo yunohost app setting my_webapp ftp_user)
is_public=$(sudo yunohost app setting my_webapp is_public)
name=$(echo $2 | cut -d '/' -f 2)
parent_dir=/var/www/webapp_$user
final_path=$parent_dir$path
netftp_path=/ftp_webapp_$user
# Modify Nginx configuration file and copy it to Nginx conf directory
sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf
sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$name.conf
# Make app public if necessary
sudo yunohost app setting my_webapp is_public -v "$is_public"
if [ "$is_public" = "Yes" ];
then
sudo yunohost app setting my_webapp skipped_uris -v "/"
fi
# Reload Nginx and regenerate SSOwat conf
sudo service nginx reload
sudo yunohost app ssowatconf

16
sources/index.html Normal file
View file

@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<body>
<h1>It works !</h1>
<p>Congratulation, you have just installed your custom web app without ftp access.</p>
<br>
<p>As a reward, here is a random cat picture:</p>
<p><img src="http://thecatapi.com/api/images/get?format=src&type=gif"></p>
</body>
</html>