1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/lutim_ynh.git synced 2024-09-03 19:36:24 +02:00
lutim_ynh/scripts/install

115 lines
3.3 KiB
Text
Raw Normal View History

2014-10-06 13:19:51 +02:00
#!/bin/bash
# Retrieve arguments
domain=$1
path=$2
admin=$3
is_public=$4
# Check if admin exists
sudo yunohost user list --json | grep -q "\"username\": \"$admin\""
if [[ ! $? -eq 0 ]]; then
echo "Wrong admin"
exit 1
fi
# Vérifie l'existence du / en fin de path
if [ $(echo "$path" | grep -c '/$') -eq 0 ]
then
path="$path/"
fi
2014-10-06 13:19:51 +02:00
# Check domain/path availability
2015-03-10 12:47:07 +01:00
sudo yunohost app checkurl $domain$path -a lutim
2014-10-06 13:19:51 +02:00
if [[ ! $? -eq 0 ]]; then
exit 1
fi
# Get an available port
port=8095
sudo yunohost app checkport $port
while [[ ! $? -eq 0 ]]; do
port=$((port+1))
sudo yunohost app checkport $port
done
# Check /var/www/$app path is available
final_path=/var/www/lutim
if [ -e "$final_path" ]
then
echo "This path already contains a folder"
exit 1
fi
2014-10-06 13:19:51 +02:00
# Add settings to YunoHost
sudo yunohost app setting lutim admin -v $admin
sudo yunohost app setting lutim domain -v $domain
sudo yunohost app setting lutim is_public -v $is_public
2014-10-06 13:19:51 +02:00
# Copy files to right place
sudo mkdir -p $final_path
# Création archive source: tar -czp -f lutim.tar.gz lutim
# Décompresse la source
tar -x -f ../sources/lutim.tar.gz
sudo cp -a lutim/. $final_path
sudo cp -a ../sources/ajouts/. $final_path
2014-10-06 13:19:51 +02:00
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/lutim.conf
# Installation du module perl carton
2015-03-10 12:47:07 +01:00
echo "Installation du module perl carton. Attention, étape très longue..."
# yes | sudo cpan Carton | sudo tee $final_path/cpan_setup.log 2>&1 > /dev/null 2>&1 # Debug
yes | sudo cpan Carton > /dev/null 2>&1
2014-10-06 13:19:51 +02:00
# Installation de perlmagick, interface perl pour imagemagick
sudo apt-get install perlmagick -qy
## Copie et configuration du fichier de conf.
2015-01-18 14:48:23 +01:00
sudo cp ../conf/lutim.conf.template $final_path/lutim.conf
sudo sed -i "s@__DOMAIN__@$domain@g" $final_path/lutim.conf
2015-03-10 12:47:07 +01:00
sudo sed -i "s@__PATH__@$path@g" $final_path/lutim.conf
sudo sed -i "s@__PORT__@$port@g" $final_path/lutim.conf
secret=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d '[A-Za-z0-9]' | sed -n 's/\(.\{24\}\).*/\1/p')
sudo sed -i "s@__SECRET__@$secret@g" $final_path/lutim.conf
2014-10-06 13:19:51 +02:00
# Mise en place des scripts init
sudo cp ../conf/lutim.init /etc/init.d/lutim
2015-01-18 14:48:23 +01:00
sudo cp ../conf/lutim.default /etc/default/lutim
2014-10-06 13:19:51 +02:00
sudo chmod +x /etc/init.d/lutim
2015-03-10 12:47:07 +01:00
sudo chown root:root /etc/init.d/lutim /etc/default/lutim
sudo sed -i "s@__FINALPATH__@$final_path/@g" /etc/default/lutim
## Mise en place des crons
sudo cp ../conf/cron_lutim /etc/cron.d/lutim
sudo sed -i "s@__FINALPATH__@$final_path/@g" /etc/cron.d/lutim
# Installation de lutim via carton
cd $final_path
sudo carton install
2014-10-06 13:19:51 +02:00
## Démarrage auto des scripts init
2015-01-18 14:48:23 +01:00
sudo update-rc.d lutim defaults
# sudo update-rc.d -f lutim remove
2014-10-06 13:19:51 +02:00
2015-01-18 14:48:23 +01:00
# Change variables in nginx configuration
sudo sed -i "s@__PATH__@$path@g" /etc/nginx/conf.d/$domain.d/lutim.conf
sudo sed -i "s@__PORT__@$port@g" /etc/nginx/conf.d/$domain.d/lutim.conf
2014-10-06 13:19:51 +02:00
2015-01-18 14:48:23 +01:00
# Set right permissions
sudo chown -R www-data: $final_path
2014-10-06 13:19:51 +02:00
# Make app public or private
if [ "$is_public" = "Yes" ];
then
sudo yunohost app setting lutim skipped_uris -v "/"
2015-03-10 12:57:48 +01:00
# else # Si l'app est privée, seul le visionnage des images est public
2015-03-10 12:47:07 +01:00
# sudo yunohost app setting lutim skipped_regex -v "/(stats|manifest.webapp|(d|m)/.+)?$"
fi
2014-10-06 13:19:51 +02:00
# Reload Nginx, start lutim and regenerate SSOwat conf
sudo service nginx reload
sudo /etc/init.d/lutim start
sudo yunohost app ssowatconf