Initial commit

This commit is contained in:
Alexandre Aubin 2017-03-11 20:12:45 -05:00
commit ddce191fdb
11 changed files with 203 additions and 0 deletions

View file

@ -0,0 +1,5 @@
<html>
<body>
This is a dummy app to test the change url feature.
</body>
</html>

View file

@ -0,0 +1,3 @@
location PATHTOCHANGE {
alias /var/www/FOLDER;
}

View file

@ -0,0 +1,36 @@
{
"name": "Change Url",
"id": "change_url_app",
"description": {
"en": "Dummy app to test change_url"
},
"license": "GPL-3+",
"maintainer": {
"name": "bram",
"email": "cortex@worlddomination.be",
"url": "http://worlddomination.be"
},
"requirements": {
"yunohost": ">> 2.4.0"
},
"multi_instance": false,
"arguments": {
"install" : [
{
"name": "domain",
"ask": {
"en": "Choose a domain"
},
"example": "domain.org"
},
{
"name": "path",
"ask": {
"en": "Choose a path"
},
"example": "/",
"default": "/"
}
]
}
}

View file

@ -0,0 +1,25 @@
set -eux
app=$YNH_APP_INSTANCE_NAME
number=$YNH_APP_INSTANCE_NUMBER
# Retrieve arguments
old_domain=$YNH_APP_OLD_DOMAIN
old_path=$YNH_APP_OLD_PATH
old_path_trimed=$YNH_APP_OLD_PATH_TRIMED
new_domain=$YNH_APP_NEW_DOMAIN
new_path=$YNH_APP_NEW_PATH
new_path_trimed=$YNH_APP_NEW_PATH_TRIMED
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
if [[ "$new_path" == "" ]]; then
sudo sed -i "s@location .\+ {@location / {@g" $nginx_conf_path
else
sudo sed -i "s@location .\+ {@location $new_path_trimed {@g" $nginx_conf_path
fi
if [ $old_domain != $new_domain ]; then
sudo mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
fi

View file

@ -0,0 +1,34 @@
set -eux
app=$YNH_APP_INSTANCE_NAME
number=$YNH_APP_INSTANCE_NUMBER
# Retrieve arguments
domain=$YNH_APP_ARG_DOMAIN
path=$YNH_APP_ARG_PATH
# Check domain/path availability
sudo yunohost app checkurl $domain$path -a $app
if [[ ! $? -eq 0 ]]; then
exit 1
fi
if [[ "$path" == "" ]]; then
sed -i "s@PATHTOCHANGE@/@g" ../conf/nginx.conf
else
sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf
fi
sudo sed -i "s@FOLDER@$app/@g" ../conf/nginx.conf
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
sudo mkdir -p /var/www/$app
sudo cp ../conf/index.html /var/www/$app
# Reload Nginx and regenerate SSOwat conf
sudo service nginx reload
sudo yunohost app setting $app unprotected_uris -v "/"
sudo yunohost app ssowatconf

View file

@ -0,0 +1,11 @@
set -eux
# See comments in install script
app=$YNH_APP_INSTANCE_NAME
domain=$(sudo yunohost app setting $app domain)
sudo rm -rf /var/www/$app
sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf
sudo service nginx reload

View file

@ -0,0 +1,5 @@
<html>
<body>
This is a dummy app to test urlregister
</body>
</html>

View file

@ -0,0 +1,3 @@
location PATHTOCHANGE {
alias /var/www/FOLDER;
}

View file

@ -0,0 +1,36 @@
{
"name": "RegisterUrl Test App",
"id": "register_url_app",
"description": {
"en": "App to test the yunohost app registerurl action"
},
"license": "GPL-3+",
"maintainer": {
"name": "Aleks",
"email": "alex.aubin@mailoo.org",
"url": "https://github.com/alexAubin/"
},
"requirements": {
"yunohost": ">> 2.4.0"
},
"multi_instance": false,
"arguments": {
"install" : [
{
"name": "domain",
"ask": {
"en": "Choose a domain"
},
"example": "domain.org"
},
{
"name": "path",
"ask": {
"en": "Choose a path"
},
"example": "/",
"default": "/"
}
]
}
}

View file

@ -0,0 +1,34 @@
set -eux
app=$YNH_APP_INSTANCE_NAME
number=$YNH_APP_INSTANCE_NUMBER
# Retrieve arguments
domain=$YNH_APP_ARG_DOMAIN
path=$YNH_APP_ARG_PATH
# Check domain/path availability
sudo yunohost app registerurl $app $domain $path
if [[ ! $? -eq 0 ]]; then
exit 1
fi
if [[ "$path" == "" ]]; then
sed -i "s@PATHTOCHANGE@/@g" ../conf/nginx.conf
else
sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf
fi
sudo sed -i "s@FOLDER@$app/@g" ../conf/nginx.conf
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
sudo mkdir -p /var/www/$app
sudo cp ../conf/index.html /var/www/$app
# Reload Nginx and regenerate SSOwat conf
sudo service nginx reload
sudo yunohost app setting $app unprotected_uris -v "/"
sudo yunohost app ssowatconf

View file

@ -0,0 +1,11 @@
set -eux
# See comments in install script
app=$YNH_APP_INSTANCE_NAME
domain=$(sudo yunohost app setting $app domain)
sudo rm -rf /var/www/$app
sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf
sudo service nginx reload