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

Removal of ftp data

This commit is contained in:
polytan02 2015-04-11 16:07:35 +01:00
parent ab802485cd
commit 708c94d90c
6 changed files with 159 additions and 58 deletions

View file

@ -1,6 +1,6 @@
{ {
"name": "Multi Instances Webapp", "name": "Multi Instances Webapp",
"id": "webapp_multi", "id": "webapp_multi_inst",
"description": { "description": {
"en": "Multi Instances Web App without FTP access", "en": "Multi Instances Web App without FTP access",
"fr": "Multi Instances Web App vide sans accès FTP" "fr": "Multi Instances Web App vide sans accès FTP"
@ -29,14 +29,6 @@
"example": "/site", "example": "/site",
"default": "/site" "default": "/site"
}, },
{
"name": "admin",
"ask": {
"en": "Choose the YunoHost user",
"fr": "Choisissez l'utilisateur YunoHost associé"
},
"example": "johndoe"
},
{ {
"name": "is_public", "name": "is_public",
"ask": { "ask": {

51
manifest_ftp.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"
}
]
}
}

View file

@ -4,8 +4,7 @@
app=webapp_multi_inst app=webapp_multi_inst
domain=$1 domain=$1
path=$2 path=$2
user=$3 is_public=$3
is_public=$4
# sitename == path without "/" # sitename == path without "/"
sitename=$(echo $path | cut -d '/' -f 2) sitename=$(echo $path | cut -d '/' -f 2)
@ -29,24 +28,6 @@ sudo yunohost app setting $app domain -v $domain
sudo yunohost app setting $app path -v $path sudo yunohost app setting $app path -v $path
sudo yunohost app setting $app sitename -v $sitename sudo yunohost app setting $app sitename -v $sitename
# 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 # Creation of folder
sudo rm -rf $final_path sudo rm -rf $final_path
sudo mkdir -p $final_path sudo mkdir -p $final_path
@ -58,33 +39,6 @@ sudo cp ../sources/index.html $final_path/
sudo chmod 775 -R $final_path sudo chmod 775 -R $final_path
sudo chown -hR www-data:www-data $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 # Modify Nginx configuration file and copy it to Nginx conf directory
sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf
sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf

104
scripts/install_ftp Normal file
View file

@ -0,0 +1,104 @@
#!/bin/bash
# Retrieve arguments
app=webapp_multi_inst
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
final_path=/var/www/webapp\_multi/$domain/$sitename
# Check domain/path availability
sudo yunohost app checkurl $domain$path -a $app
if [[ ! $? -eq 0 ]]; then
exit 1
fi
sudo yunohost app setting $app final_path -v $final_path
sudo yunohost app setting $app domain -v $domain
sudo yunohost app setting $app path -v $path
sudo yunohost app setting $app sitename -v $sitename
# 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 -p $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 "/"
else
sudo yunohost app setting $app protected_uris -v "/"
fi
# Reload Nginx and regenerate SSOwat conf
sudo service nginx reload
sudo yunohost app ssowatconf

View file

@ -2,7 +2,7 @@
app=webapp_multi_inst app=webapp_multi_inst
user=$(sudo yunohost app setting $app user) #user=$(sudo yunohost app setting $app user)
path=$(sudo yunohost app setting $app path) path=$(sudo yunohost app setting $app path)
sitename=$(sudo yunohost app setting $app sitename) sitename=$(sudo yunohost app setting $app sitename)
domain=$(sudo yunohost app setting $app domain) domain=$(sudo yunohost app setting $app domain)

View file

@ -6,7 +6,7 @@ app=webapp_multi_inst
domain=$(sudo yunohost app setting $app domain) domain=$(sudo yunohost app setting $app domain)
path=$(sudo yunohost app setting $app path) path=$(sudo yunohost app setting $app path)
sitename=$(sudo yunohost app setting $app sitename) sitename=$(sudo yunohost app setting $app sitename)
user=$(sudo yunohost app setting $app user) #user=$(sudo yunohost app setting $app user)
is_public=$(sudo yunohost app setting $app is_public) is_public=$(sudo yunohost app setting $app is_public)
final_path=$(sudo yunohost app setting $app final_path) final_path=$(sudo yunohost app setting $app final_path)