mirror of
https://github.com/YunoHost-Apps/lstu_ynh.git
synced 2024-09-03 19:36:12 +02:00
Update install
This commit is contained in:
parent
f19fe9b944
commit
0c908b422d
1 changed files with 63 additions and 30 deletions
|
@ -68,6 +68,7 @@ ynh_app_setting_set $app port $port
|
|||
#=================================================
|
||||
|
||||
ynh_install_app_dependencies build-essential libssl-dev libpq-dev libpng-dev
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
|
@ -83,69 +84,98 @@ sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
|||
|
||||
if [ $is_public -eq 1 ];
|
||||
then
|
||||
sudo sed -i "s@#--PRIVATE--@@g" /etc/nginx/conf.d/$domain.d/$app.conf
|
||||
ynh_replace_string "#--PRIVATE--" "" "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
fi
|
||||
|
||||
## Copy and fix variable into lstu config
|
||||
sudo cp ../conf/lstu.conf.template "${final_path}/lstu.conf"
|
||||
sudo sed -i "s@__DOMAIN__@$domain@g" "${final_path}/lstu.conf"
|
||||
sudo sed -i "s@__PATH__@$path@g" "${final_path}/lstu.conf"
|
||||
sudo sed -i "s@__PORT__@$port@g" "${final_path}/lstu.conf"
|
||||
cp ../conf/lstu.conf.template "${final_path}/lstu.conf"
|
||||
ynh_replace_string "__DOMAIN__" "$domain" "$final_path/lstu.conf"
|
||||
ynh_replace_string "__PATH__" "$path_url" "$final_path/lstu.conf"
|
||||
ynh_replace_string "__PORT__" "$port" "$final_path/lstu.conf"
|
||||
|
||||
secret=$(ynh_string_random 24)
|
||||
CHECK_VAR "$secret" "secret empty"
|
||||
sudo sed -i "s@__SECRET__@$secret@g" "${final_path}/lstu.conf"
|
||||
STORE_MD5_CONFIG "lstu.conf" "${final_path}/lstu.conf"
|
||||
ynh_replace_string "__SECRET__" "$secret" "${final_path}/lstu.conf"
|
||||
ynh_store_file_checksum "lstu.conf" "${final_path}/lstu.conf"
|
||||
|
||||
# Install systemd script
|
||||
sudo cp ../conf/lstu.service /etc/systemd/system/lstu.service
|
||||
sudo chown root: /etc/systemd/system/lstu.service
|
||||
sudo sed -i "s@__FINALPATH__@$final_path/@g" /etc/systemd/system/lstu.service
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
#=================================================
|
||||
|
||||
# Install logrotate
|
||||
sudo cp ../conf/logrotate /etc/logrotate.d/$app
|
||||
sudo sed -i "s@__FINALPATH__@$final_path@g" /etc/logrotate.d/$app
|
||||
# Create a dedicated systemd config
|
||||
ynh_systemd_config
|
||||
|
||||
#=================================================
|
||||
# SETUP LOGROTATE
|
||||
#=================================================
|
||||
|
||||
# Use logrotate to manage application logfile(s)
|
||||
ynh_use_logrotate
|
||||
|
||||
#=================================================
|
||||
# Installation of Carton
|
||||
#=================================================
|
||||
|
||||
# Install Carton
|
||||
echo yes | sudo cpan Carton
|
||||
|
||||
# Install lstu's dependencies via carton
|
||||
sudo mkdir -p /var/log/$app/
|
||||
cd $final_path
|
||||
sudo carton install 2>&1 | sudo tee -a "/var/log/$app/setup_carton.log"
|
||||
#=================================================
|
||||
# Installation with Carton
|
||||
#=================================================
|
||||
|
||||
pushd $final_path
|
||||
carton install 2>&1 | sudo tee -a "/var/log/$app/setup_carton.log"
|
||||
popd
|
||||
|
||||
#=================================================
|
||||
# Change variables in nginx configuration
|
||||
sudo sed -i "s@__PATH__@$path@g" /etc/nginx/conf.d/$domain.d/$app.conf
|
||||
sudo sed -i "s@__PORT__@$port@g" /etc/nginx/conf.d/$domain.d/$app.conf
|
||||
#=================================================
|
||||
|
||||
ynh_replace_string "__PATH__" "$path" "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_replace_string "__PORT__" "$port" "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# Make app public or private
|
||||
#=================================================
|
||||
|
||||
ynh_app_setting_set $app skipped_uris "/"
|
||||
if [ $is_public -eq 0 ];
|
||||
then # If the app is private, only the shortened URLs are publics
|
||||
if [ "$path" == "/" ]; then
|
||||
path=""
|
||||
fi
|
||||
ynh_app_setting_set $app protected_regex "$domain_regex$path/login$","$domain_regex$path/logout$","$domain_regex$path/api$","$domain_regex$path/extensions$","$domain_regex$path/stats$","$domain_regex$path/d/.*$","$domain_regex$path/a$","$domain_regex$path/$"
|
||||
ynh_app_setting_set $app protected_regex "$domain_regex$path_url/login$","$domain_regex$path_url/logout$","$domain_regex$path_url/api$","$domain_regex$path_url/extensions$","$domain_regex$path_url/stats$","$domain_regex$path_url/d/.*$","$domain_regex$path_url/a$","$domain_regex$path_url/$"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# Making log symbolic link to /var/log
|
||||
sudo touch /var/log/$app/production.log
|
||||
sudo chown www-data: /var/log/$app/production.log
|
||||
sudo ln -s /var/log/$app/production.log "$final_path/log/production.log"
|
||||
#=================================================
|
||||
|
||||
touch /var/log/$app/production.log
|
||||
chown www-data: /var/log/$app/production.log
|
||||
ln -s /var/log/$app/production.log "$final_path/log/production.log"
|
||||
|
||||
#=================================================
|
||||
# Configure owner
|
||||
#=================================================
|
||||
|
||||
sudo chown -R www-data: $final_path
|
||||
|
||||
#=================================================
|
||||
# Start lstu
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl start lstu.service
|
||||
sudo systemctl enable lstu.service
|
||||
#=================================================
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl start lstu.service
|
||||
systemctl enable lstu.service
|
||||
|
||||
#=================================================
|
||||
# Set right permissions on new files created at first start
|
||||
#=================================================
|
||||
|
||||
sudo chown -R www-data: "$final_path"
|
||||
|
||||
#=================================================
|
||||
# Add lstu as a service
|
||||
sudo yunohost service add lstu -l $final_path/log/production.log
|
||||
#=================================================
|
||||
|
||||
if [ $is_public -eq 0 ];
|
||||
then
|
||||
|
@ -155,5 +185,8 @@ then
|
|||
sudo yunohost app ssowatconf
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# Reload Nginx
|
||||
#=================================================
|
||||
|
||||
sudo service nginx reload
|
||||
|
|
Loading…
Add table
Reference in a new issue