mirror of
https://github.com/YunoHost-Apps/etherpad_ynh.git
synced 2024-09-03 18:36:10 +02:00
added upgrade script and refactored install
This commit is contained in:
parent
0595f102b1
commit
44120e9a5e
2 changed files with 94 additions and 23 deletions
|
@ -44,46 +44,49 @@ if ! ynh_package_is_installed "nodejs-legacy" ; then
|
||||||
sudo apt-get install nodejs-legacy npm -y
|
sudo apt-get install nodejs-legacy npm -y
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Copy files to the right place
|
# create app dir and compy sources
|
||||||
final_path=/var/www/$app
|
final_path=/var/www/$app
|
||||||
sudo mkdir -p $final_path
|
sudo mkdir -p $final_path
|
||||||
|
|
||||||
sudo cp -a ../sources/* $final_path
|
sudo cp -a ../sources/* $final_path
|
||||||
|
|
||||||
sudo cp ../conf/settings.json $final_path
|
sudo cp ../conf/settings.json $final_path
|
||||||
|
|
||||||
sudo cp ../conf/etherpad-lite /etc/init.d/$app
|
|
||||||
sudo sed -i "s/APPTOCHANGE/$app/g" /etc/init.d/$app
|
|
||||||
sudo chmod +x /etc/init.d/$app
|
|
||||||
sudo update-rc.d $app defaults
|
|
||||||
|
|
||||||
sudo mkdir /var/log/$app
|
|
||||||
sudo touch /var/log/$app/$app.log
|
|
||||||
sudo chown www-data /var/log/$app/$app.log
|
|
||||||
|
|
||||||
sudo npm cache clear
|
|
||||||
sudo $final_path/bin/installDeps.sh > /dev/null 2>&1
|
|
||||||
sudo npm install forever -g > /dev/null 2>&1
|
|
||||||
|
|
||||||
# Change variables in etherpad configuration
|
# Change variables in etherpad configuration
|
||||||
sudo sed -i "s/yunouser/$dbuser/g" $final_path/settings.json
|
sudo sed -i "s/yunouser/$dbuser/g" $final_path/settings.json
|
||||||
sudo sed -i "s/yunopass/$dbpass/g" $final_path/settings.json
|
sudo sed -i "s/yunopass/$dbpass/g" $final_path/settings.json
|
||||||
sudo sed -i "s/yunobase/$dbname/g" $final_path/settings.json
|
sudo sed -i "s/yunobase/$dbname/g" $final_path/settings.json
|
||||||
sudo sed -i "s/KEY/$key/g" $final_path/settings.json
|
sudo sed -i "s/KEY/$key/g" $final_path/settings.json
|
||||||
|
|
||||||
|
sudo npm cache clear
|
||||||
|
sudo $final_path/bin/installDeps.sh > /dev/null 2>&1
|
||||||
|
sudo npm install forever -g > /dev/null 2>&1
|
||||||
|
|
||||||
# Set permissions to etherpad directory
|
# Set permissions to etherpad directory
|
||||||
sudo chown -R www-data: $final_path
|
sudo chown -R www-data: $final_path
|
||||||
|
|
||||||
# Modify Nginx configuration file and copy it to Nginx conf directory
|
# service
|
||||||
sed -i "s@YNH_EXAMPLE_PATH@$path@g" ../conf/nginx.conf
|
sudo cp ../conf/etherpad-lite /etc/init.d/$app
|
||||||
sed -i "s@YNH_EXAMPLE_PORT@$port@g" ../conf/nginx.conf
|
sudo sed -i "s/APPTOCHANGE/$app/g" /etc/init.d/$app
|
||||||
sed -i "s@YNH_EXEMPLE_DOMAIN@$domain@g" ../conf/nginx.conf
|
sudo chmod +x /etc/init.d/$app
|
||||||
|
sudo update-rc.d $app defaults
|
||||||
|
|
||||||
|
# logs
|
||||||
|
sudo mkdir /var/log/$app
|
||||||
|
sudo touch /var/log/$app/$app.log
|
||||||
|
sudo chown www-data /var/log/$app/$app.log
|
||||||
|
|
||||||
|
# nginx
|
||||||
|
$nginx_conf_path=/etc/nginx/conf.d/$domain.d/$app.conf
|
||||||
if [ "$path" = "" ];
|
if [ "$path" = "" ];
|
||||||
then
|
then
|
||||||
sudo cp ../conf/nginx.conf-nosub /etc/nginx/conf.d/$domain.d/$app.conf
|
sudo cp ../conf/nginx.conf-nosub $nginx_conf_path
|
||||||
else
|
else
|
||||||
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
sudo cp ../conf/nginx.conf $nginx_conf_path
|
||||||
|
# Modify Nginx configuration file and copy it to Nginx conf directory
|
||||||
|
sudo sed -i "s@YNH_EXAMPLE_PATH@$path@g" $nginx_conf_path
|
||||||
|
sudo sed -i "s@YNH_EXAMPLE_PORT@$port@g" $nginx_conf_path
|
||||||
|
sudo sed -i "s@YNH_EXEMPLE_DOMAIN@$domain@g" $nginx_conf_path
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Reload Nginx and regenerate SSOwat conf
|
# Reload Nginx and regenerate SSOwat conf
|
||||||
sudo service nginx reload
|
sudo service nginx reload
|
||||||
# If app is public, add url to SSOWat conf as skipped_uris
|
# If app is public, add url to SSOWat conf as skipped_uris
|
||||||
|
@ -91,5 +94,7 @@ if [[ $is_public -eq 1 ]]; then
|
||||||
# unprotected_uris allows SSO credentials to be passed anyway.
|
# unprotected_uris allows SSO credentials to be passed anyway.
|
||||||
ynh_app_setting_set "$app" unprotected_uris "/"
|
ynh_app_setting_set "$app" unprotected_uris "/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo yunohost app ssowatconf
|
sudo yunohost app ssowatconf
|
||||||
|
|
||||||
sudo service etherpad-lite start
|
sudo service etherpad-lite start
|
||||||
|
|
|
@ -1,3 +1,69 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#TODO
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
# Source YunoHost helpers
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
# Retrieve app settings
|
||||||
|
domain=$(ynh_app_setting_get "$app" domain)
|
||||||
|
path=$(ynh_app_setting_get "$app" path)
|
||||||
|
dbuser=$(ynh_app_setting_get "$app" dbuser)
|
||||||
|
dbname=$(ynh_app_setting_get "$app" dbname)
|
||||||
|
|
||||||
|
root_pwd=$(sudo cat /etc/yunohost/mysql)
|
||||||
|
|
||||||
|
# Remove trailing "/" for next commands
|
||||||
|
path=${path%/}
|
||||||
|
|
||||||
|
|
||||||
|
# create app dir and compy sources
|
||||||
|
final_path=/var/www/$app
|
||||||
|
sudo mkdir -p $final_path
|
||||||
|
|
||||||
|
sudo cp -a ../sources/* $final_path
|
||||||
|
|
||||||
|
sudo cp ../conf/settings.json $final_path
|
||||||
|
# Change variables in etherpad configuration
|
||||||
|
sudo sed -i "s/yunouser/$dbuser/g" $final_path/settings.json
|
||||||
|
sudo sed -i "s/yunopass/$dbpass/g" $final_path/settings.json
|
||||||
|
sudo sed -i "s/yunobase/$dbname/g" $final_path/settings.json
|
||||||
|
sudo sed -i "s/KEY/$key/g" $final_path/settings.json
|
||||||
|
|
||||||
|
sudo npm cache clear
|
||||||
|
sudo $final_path/bin/installDeps.sh > /dev/null 2>&1
|
||||||
|
sudo npm install forever -g > /dev/null 2>&1
|
||||||
|
|
||||||
|
# Set permissions to etherpad directory
|
||||||
|
sudo chown -R www-data: $final_path
|
||||||
|
|
||||||
|
# service
|
||||||
|
sudo cp ../conf/etherpad-lite /etc/init.d/$app
|
||||||
|
sudo sed -i "s/APPTOCHANGE/$app/g" /etc/init.d/$app
|
||||||
|
sudo chmod +x /etc/init.d/$app
|
||||||
|
sudo update-rc.d $app defaults
|
||||||
|
|
||||||
|
# nginx
|
||||||
|
$nginx_conf_path=/etc/nginx/conf.d/$domain.d/$app.conf
|
||||||
|
if [ "$path" = "" ];
|
||||||
|
then
|
||||||
|
sudo cp ../conf/nginx.conf-nosub $nginx_conf_path
|
||||||
|
else
|
||||||
|
sudo cp ../conf/nginx.conf $nginx_conf_path
|
||||||
|
# Modify Nginx configuration file and copy it to Nginx conf directory
|
||||||
|
sudo sed -i "s@YNH_EXAMPLE_PATH@$path@g" $nginx_conf_path
|
||||||
|
sudo sed -i "s@YNH_EXAMPLE_PORT@$port@g" $nginx_conf_path
|
||||||
|
sudo sed -i "s@YNH_EXEMPLE_DOMAIN@$domain@g" $nginx_conf_path
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Reload Nginx and regenerate SSOwat conf
|
||||||
|
sudo service nginx reload
|
||||||
|
# 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 "/"
|
||||||
|
fi
|
||||||
|
|
||||||
|
sudo yunohost app ssowatconf
|
||||||
|
|
||||||
|
sudo service etherpad-lite start
|
||||||
|
|
Loading…
Add table
Reference in a new issue