mirror of
https://github.com/YunoHost-Apps/scrumblr_ynh.git
synced 2024-09-03 20:16:29 +02:00
Update install
This commit is contained in:
parent
9056b40e52
commit
2846bc548a
1 changed files with 129 additions and 19 deletions
148
scripts/install
148
scripts/install
|
@ -1,57 +1,163 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -eu
|
set -eu
|
||||||
source .fonctions
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC STARTING
|
||||||
|
#=================================================
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MANAGE FAILURE OF THE SCRIPT
|
# MANAGE FAILURE OF THE SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_check_error # Active trap pour arrêter le script si une erreur est détectée.
|
ynh_clean_setup () {
|
||||||
|
# Nettoyage des résidus d'installation non pris en charge par le script remove.
|
||||||
|
if test -n "$PID_TAIL"
|
||||||
|
then
|
||||||
|
SUPPRESS_WARNING kill -s 15 $PID_TAIL # Arrête l'exécution de tail.
|
||||||
|
ynh_secure_remove "$tempfile"
|
||||||
|
fi
|
||||||
|
echo ""
|
||||||
|
}
|
||||||
|
ynh_abort_if_errors # Active trap pour arrêter le script si une erreur est détectée.
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Retrieve arguments
|
|
||||||
domain=$YNH_APP_ARG_DOMAIN
|
domain=$YNH_APP_ARG_DOMAIN
|
||||||
path=$YNH_APP_ARG_PATH
|
path_url=$YNH_APP_ARG_PATH
|
||||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
script_dir=$PWD
|
script_dir=$PWD
|
||||||
|
|
||||||
# Vérifie que les variables ne sont pas vides.
|
#=================================================
|
||||||
|
# CHECK IF THE APP CAN BE INSTALLED WITH THIS ARGS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
if sudo yunohost domain list | grep -q $domain # Vérifie la liste des domaines
|
||||||
|
then # Si le domaine existe dans Yunohost
|
||||||
|
if sudo yunohost app map | grep -q $domain # Vérifie la liste des apps par domaine
|
||||||
|
then # Si une app est installée sur ce domaine.
|
||||||
|
WARNING echo "An app is already installed on the domain $domain. Mypads needs a whole domain or subdomain to himself."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
CHECK_DOMAINPATH # Vérifie la disponibilité du path et du domaine.
|
CHECK_DOMAINPATH # Vérifie la disponibilité du path et du domaine.
|
||||||
path=$(ynh_normalize_url_path $path) # Vérifie et corrige la syntaxe du path.
|
|
||||||
CHECK_FINALPATH # Vérifie que le dossier de destination n'est pas déjà utilisé.
|
CHECK_FINALPATH # Vérifie que le dossier de destination n'est pas déjà utilisé.
|
||||||
|
|
||||||
# Install dependency to convert tracks to a readable format for the browser
|
#=================================================
|
||||||
sudo apt-get update
|
# STORE SETTINGS FROM MANIFEST
|
||||||
sudo apt-get -y -qq install redis-server php5-redis nodejs-legacy nodejs npm
|
#=================================================
|
||||||
check_or_install_npm
|
|
||||||
|
|
||||||
|
ynh_app_setting_set $app domain $domain
|
||||||
|
ynh_app_setting_set $app is_public $is_public
|
||||||
|
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# STANDARD MODIFICATIONS
|
||||||
|
#=================================================
|
||||||
|
# FIND AND OPEN A PORT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
port=$(ynh_find_port 4000) # Cherche un port libre.
|
||||||
|
ynh_app_setting_set $app port $port
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# INSTALL NODEJS
|
||||||
|
#=================================================
|
||||||
|
version=6.2.0
|
||||||
|
ynh_install_nodejs 6.2.0
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# Install dependency to convert tracks to a readable format for the browser
|
||||||
|
#=================================================
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get -y -qq install redis-server php5-redis
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CREATE DEDICATED USER
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_system_user_create $app /home/$app # Créer un utilisateur système dédié à l'app
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SPECIFIC SETUP
|
||||||
|
#=================================================
|
||||||
|
# HANDLE LOG FILES AND LOGROTATE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Créer le dossier de log
|
||||||
|
sudo mkdir -p /var/log/$app
|
||||||
|
sudo touch /var/log/$app/scrumblr.log
|
||||||
|
install_log=/var/log/$app/installation.log
|
||||||
|
sudo touch $install_log
|
||||||
|
sudo chown $app -R /var/log/$app
|
||||||
|
sudo chown admin -R $install_log
|
||||||
|
|
||||||
|
# Configuration de logrotate
|
||||||
|
ynh_use_logrotate
|
||||||
|
|
||||||
|
#=================================================
|
||||||
# Copy files to the right place
|
# Copy files to the right place
|
||||||
|
#=================================================
|
||||||
|
|
||||||
final_path=/var/www/$app
|
final_path=/var/www/$app
|
||||||
extract_source
|
ynh_app_setting_set $app final_path $final_path
|
||||||
|
ynh_setup_source $final_path
|
||||||
|
|
||||||
# Files owned by root, www-data can just read
|
# Files owned by root, www-data can just read
|
||||||
sudo chown www-data:www-data $final_path -R
|
sudo chown www-data:www-data $final_path -R
|
||||||
sudo chmod 755 $final_path -R
|
sudo chmod 755 $final_path -R
|
||||||
|
|
||||||
|
|
||||||
|
#=================================================
|
||||||
# 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@YNH_WWW_PATH@$path@g" ../conf/nginx.conf
|
#=================================================
|
||||||
sed -i "s@YNH_WWW_ALIAS@$final_path/@g" ../conf/nginx.conf
|
|
||||||
|
ynh_nginx_config
|
||||||
nginxconf=/etc/nginx/conf.d/$domain.d/$app.conf
|
nginxconf=/etc/nginx/conf.d/$domain.d/$app.conf
|
||||||
sudo cp ../conf/nginx.conf $nginxconf
|
|
||||||
sudo chown root: $nginxconf
|
sudo chown root: $nginxconf
|
||||||
sudo chmod 600 $nginxconf
|
sudo chmod 600 $nginxconf
|
||||||
|
ynh_systemd_config
|
||||||
|
ynh_replace_string "__NODEJS__" "$nodejs_use_version" "/etc/systemd/system/$app.service"
|
||||||
|
ynh_replace_string "__ENV_PATH__" "$PATH" "/etc/systemd/system/$app.service"
|
||||||
|
ynh_replace_string "__NODE__" "$nodejs_path" "/etc/systemd/system/$app.service"
|
||||||
|
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# Install Scrumblr
|
||||||
|
#=================================================
|
||||||
|
|
||||||
pushd $final_path
|
pushd $final_path
|
||||||
sudo npm install
|
ynh_use_nodejs
|
||||||
|
sudo_path npm install >> $install_log 2>&1
|
||||||
popd
|
popd
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# Enable Database
|
||||||
|
#=================================================
|
||||||
|
|
||||||
sudo service redis-server start
|
sudo service redis-server start
|
||||||
sudo yunohost firewall allow Both 85
|
sudo yunohost firewall allow Both $port
|
||||||
pre_inst_scrumblr
|
|
||||||
sudo service scrumblr start
|
#=================================================
|
||||||
|
# Configure init script
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
sudo systemctl daemon-reload
|
||||||
|
sudo systemctl enable "$app".service
|
||||||
sudo systemctl start "$app".service
|
sudo systemctl start "$app".service
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# Set Public or private
|
||||||
|
#=================================================
|
||||||
|
|
||||||
ynh_app_setting_set "$app" is_public "$is_public"
|
ynh_app_setting_set "$app" is_public "$is_public"
|
||||||
if [ "$is_public" = 0 ];
|
if [ "$is_public" = 0 ];
|
||||||
|
@ -59,6 +165,10 @@ then
|
||||||
ynh_app_setting_set "$app" unprotected_uris "/"
|
ynh_app_setting_set "$app" unprotected_uris "/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# Reload Service
|
||||||
|
#=================================================
|
||||||
|
|
||||||
sudo service nginx reload
|
sudo service nginx reload
|
||||||
sudo yunohost service add "$app" --log /var/log/"$app"/"$app".log
|
sudo yunohost service add "$app" --log /var/log/"$app"/"$app".log
|
||||||
sudo yunohost app ssowatconf
|
sudo yunohost app ssowatconf
|
||||||
|
|
Loading…
Add table
Reference in a new issue