1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/my_webapp_ynh.git synced 2024-09-03 19:46:26 +02:00
This commit is contained in:
Kload 2014-04-20 19:33:07 +02:00
commit bcb80b94f7
9 changed files with 215 additions and 0 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
*.swp

4
README.md Normal file
View file

@ -0,0 +1,4 @@
Roundcube for YunoHost
----------------------
http://roundcube.net/

6
conf/ldap.conf Normal file
View file

@ -0,0 +1,6 @@
LDAPBaseDN ou=users,dc=yunohost,dc=org
LDAPFilter (&(objectClass=mailAccount)(uid=FTPUSER))
LDAPHomeDir FTPDIR
LDAPAuthMethod BIND
LDAPDefaultHomeDirectory FTPDIR

12
conf/nginx.conf Normal file
View file

@ -0,0 +1,12 @@
location PATHTOCHANGE {
alias ALIASTOCHANGE;
index index.php index.html index.htm;
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;
}
}

52
manifest.json Normal file
View file

@ -0,0 +1,52 @@
{
"name": "Custom Webapp + FTP",
"id": "my_webapp",
"description": {
"en": "Empty App with FTP access to the web directory",
"fr": "App vide avec un accès FTP au répertoire Web"
},
"developer": {
"name": "kload",
"email": "kload@kload.fr",
"url": "http://kload.fr"
},
"multi_instance": "false",
"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 who will be able to upload documents via FTP",
"fr": "Choisissez l'utilisateur YunoHost qui sera capable d'envoyer des documents via FTP"
},
"example": "johndoe"
},
{
"name": "is_public",
"ask": {
"en": "Is it a public website ?",
"fr": "Est-ce un site public ?"
},
"choices": ["Yes", "No"],
"default": "Yes"
}
]
}
}

75
scripts/install Normal file
View file

@ -0,0 +1,75 @@
#!/bin/bash
# Retrieve arguments
domain=$1
path=$2
user=$3
is_public=$4
final_path=/var/www/my_webapp
# Check domain/path availability
sudo yunohost app checkurl $domain$path -a my_webapp
if [[ ! $? -eq 0 ]]; then
exit 1
fi
# Check user
ls /home | grep $user
if [[ ! $? -eq 0 ]]; then
echo "Wrong user"
exit 1
fi
sudo yunohost app setting my_webapp ftp_user -v $user
# Check port availability
sudo yunohost app checkport 21
if [[ ! $? -eq 0 ]]; then
exit 1
fi
# Open port in firewall
sudo yunohost firewall allow TCP 21 > /dev/null 2>&1
# Install debian dependencies
sudo apt-get install pure-ftpd-ldap -y -qq
# Change user ID in configurations
sed -i "s/FTPUSER/$user/g" ../conf/ldap.conf
sed -i "s/FTPDIR/$final_path/g" ../conf/ldap.conf
sed -i "s/FTPUSER/$user/g" ../sources/index.html
sed -i "s/HOST/$domain/g" ../sources/index.html
# Copy files to the right place
sudo mkdir -p $final_path
sudo cp ../sources/index.html $final_path/
# 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/my_webapp.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
# Adapt PureFTPd configuration
sudo cp ../conf/ldap.conf /etc/pure-ftpd/db/
sudo sh -c 'echo "yes" > /etc/pure-ftpd/conf/NoAnonymous'
sudo sh -c 'echo "yes" > /etc/pure-ftpd/conf/ChrootEveryone'
sudo sh -c 'echo "no" > /etc/pure-ftpd/conf/UnixAuthentication'
sudo sh -c 'echo "50000 50100" > /etc/pure-ftpd/conf/PassivePortRange'
# Register service to YunoHost monitoring
sudo yunohost app service pure-ftpd-ldap --log "/var/log/pure-ftpd/transfer.log"
# Reload Nginx, restart PureFTPd and regenerate SSOwat conf
sudo service nginx reload
sudo service pure-ftpd-ldap restart
sudo yunohost app ssowatconf

13
scripts/remove Normal file
View file

@ -0,0 +1,13 @@
#!/bin/bash
domain=$(sudo yunohost app setting my_webapp domain)
sudo service pure-ftpd-ldap stop
sudo apt-get remove -y -qq pure-ftpd-ldap pure-ftpd-common
sudo yunohost app service -R pure-ftpd-ldap
sudo rm -rf /var/www/my_webapp
sudo rm -f /etc/nginx/conf.d/$domain.d/my_webapp.conf
sudo service nginx reload
sudo yunohost app ssowatconf

35
scripts/upgrade Normal file
View file

@ -0,0 +1,35 @@
#!/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)
final_path=/var/www/my_webapp
# Change user ID in configurations
sed -i "s/FTPUSER/$user/g" ../conf/ldap.conf
sed -i "s/FTPDIR/$final_path/g" ../conf/ldap.conf
# 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/my_webapp.conf
# Make app public if necessary
if [ $is_public = "Yes" ];
then
sudo yunohost app setting my_webapp skipped_uris -v "/"
fi
# Adapt PureFTPd configuration
sudo cp ../conf/ldap.conf /etc/pure-ftpd/db/
sudo sh -c 'echo "yes" > /etc/pure-ftpd/conf/NoAnonymous'
sudo sh -c 'echo "yes" > /etc/pure-ftpd/conf/ChrootEveryone'
sudo sh -c 'echo "no" > /etc/pure-ftpd/conf/UnixAuthentication'
sudo sh -c 'echo "50000 50100" > /etc/pure-ftpd/conf/PassivePortRange'
# Reload Nginx, restart PureFTPd and regenerate SSOwat conf
sudo service nginx reload
sudo service pure-ftpd-ldap restart
sudo yunohost app ssowatconf

17
sources/index.html Normal file
View file

@ -0,0 +1,17 @@
<!DOCTYPE html>
<html>
<body>
<h1>It works !</h1>
<p>Congratulation, you have just installed your custom web app.</p>
<p>You can access to the directory of this web page by connecting as <strong>FTPUSER</strong> to your server <strong>HOST</strong> via <strong>FTP</strong> on the standard port 21.</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>