mirror of
https://github.com/YunoHost-Apps/lutim_ynh.git
synced 2024-09-03 19:36:24 +02:00
systemd au lieu de sysvinit
This commit is contained in:
parent
d34ff37e0f
commit
e0edfbfd77
10 changed files with 122 additions and 48 deletions
|
@ -8,3 +8,6 @@ Application d'hébergement et de partage d'images anonyme.
|
|||
https://lut.im
|
||||
|
||||
Le script installe le module perl *carton* via cpan et les paquets *fonts-droid* *ghostscript* *gsfonts* *imagemagick-common* *libavahi-client3* *libavahi-common-data* *libavahi-common3* *libcups2* *libcupsimage2* *libgs9* *libgs9-common* *libijs-0.35* *libjasper1* *libjbig0* *libjbig2dec0* *liblcms2-2* *liblqr-1-0* *libmagickcore5* *libpaper-utils* *libpaper1* *libtiff4* *perlmagick* *poppler-data*.
|
||||
|
||||
Mise à jour du package:
|
||||
sudo yunohost app upgrade -u https://github.com/maniackcrudelis/lutim_ynh lutim
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
# LDIR is the path where you installed Lutim
|
||||
# It has to end with a final /
|
||||
LDIR=__FINALPATH__
|
||||
|
||||
# USER is the user who will launch Lutim
|
||||
USER=www-data
|
||||
|
|
|
@ -26,6 +26,11 @@ then
|
|||
echo "LDIR variable is empty, please fill it in /etc/default/lutim"
|
||||
exit 0
|
||||
fi
|
||||
if [ -z $USER ]
|
||||
then
|
||||
echo "USER variable is empty, please fill it in /etc/default/lutim"
|
||||
exit 0
|
||||
fi
|
||||
else
|
||||
echo "Missing /etc/default/lutim file"
|
||||
exit 0
|
||||
|
@ -49,7 +54,7 @@ do_start()
|
|||
# 2 if daemon could not be started
|
||||
|
||||
cd $LDIR
|
||||
carton exec hypnotoad $DAEMON >> /var/log/lutim/production.log 2>&1
|
||||
su $USER -c "carton exec hypnotoad $DAEMON >> /var/log/lutim/production.log 2>&1"
|
||||
return "$?"
|
||||
}
|
||||
|
||||
|
@ -62,8 +67,7 @@ do_stop()
|
|||
# other if a failure occurred
|
||||
|
||||
cd $LDIR
|
||||
carton exec hypnotoad -s $DAEMON >> /var/log/lutim/production.log 2>&1
|
||||
|
||||
su $USER -c "carton exec hypnotoad -s $DAEMON >> /var/log/lutim/production.log 2>&1"
|
||||
return "$?"
|
||||
}
|
||||
|
||||
|
@ -75,14 +79,11 @@ do_status()
|
|||
pgrep -lf $DAEMON >/dev/null 2>&1
|
||||
if [ "$?" = "0" ]; then
|
||||
log_progress_msg "$NAME is running"
|
||||
log_end_msg 0
|
||||
else
|
||||
log_progress_msg "$NAME is NOT running"
|
||||
log_end_msg 1
|
||||
log_failure_msg "$NAME is NOT running but PID file exists"
|
||||
fi
|
||||
else
|
||||
log_progress_msg "$NAME is NOT running"
|
||||
log_end_msg 1
|
||||
log_failure_msg "$NAME is NOT running"
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -105,7 +106,7 @@ case "$1" in
|
|||
log_end_msg 0
|
||||
;;
|
||||
2)
|
||||
log_progress_msg "failed"
|
||||
log_failure_msg "failed"
|
||||
log_end_msg 1
|
||||
;;
|
||||
esac
|
||||
|
@ -118,7 +119,7 @@ case "$1" in
|
|||
log_end_msg 0
|
||||
;;
|
||||
2)
|
||||
log_progress_msg "failed"
|
||||
log_failure_msg "failed"
|
||||
log_end_msg 1
|
||||
;;
|
||||
esac
|
||||
|
@ -138,16 +139,16 @@ case "$1" in
|
|||
log_end_msg 0
|
||||
;;
|
||||
*)
|
||||
log_progress_msg "failed"
|
||||
log_failure_msg "failed"
|
||||
log_end_msg 1
|
||||
;;
|
||||
esac
|
||||
else
|
||||
log_progress_msg "$NAME is NOT running. Unable to stop"
|
||||
log_failure_msg "$NAME is NOT running. Unable to stop"
|
||||
log_end_msg 1
|
||||
fi
|
||||
else
|
||||
log_progress_msg "$NAME is NOT running. Unable to stop"
|
||||
log_failure_msg "$NAME is NOT running. Unable to stop"
|
||||
log_end_msg 1
|
||||
fi
|
||||
;;
|
||||
|
@ -159,13 +160,14 @@ case "$1" in
|
|||
reload)
|
||||
log_daemon_msg "Reloading $NAME"
|
||||
do_start
|
||||
sleep 1
|
||||
case "$?" in
|
||||
0|1)
|
||||
log_progress_msg "done"
|
||||
log_end_msg 0
|
||||
;;
|
||||
2)
|
||||
log_progress_msg "failed"
|
||||
log_failure_msg "failed"
|
||||
log_end_msg 1
|
||||
;;
|
||||
esac
|
||||
|
@ -173,7 +175,7 @@ case "$1" in
|
|||
restart)
|
||||
log_daemon_msg "Restarting $NAME"
|
||||
do_stop
|
||||
sleep 1
|
||||
sleep 6
|
||||
do_start
|
||||
case "$?" in
|
||||
0|1)
|
||||
|
@ -181,7 +183,7 @@ case "$1" in
|
|||
log_end_msg 0
|
||||
;;
|
||||
2)
|
||||
log_progress_msg "failed";
|
||||
log_failure_msg "failed";
|
||||
log_end_msg 1
|
||||
;;
|
||||
esac
|
||||
|
|
18
conf/lutim.service
Normal file
18
conf/lutim.service
Normal file
|
@ -0,0 +1,18 @@
|
|||
[Unit]
|
||||
Description=Image hosting and sharing service
|
||||
Documentation=https://git.framasoft.org/luc/lutim
|
||||
Requires=network.target
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
User=www-data
|
||||
RemainAfterExit=yes
|
||||
WorkingDirectory=__FINALPATH__
|
||||
PIDFile=__FINALPATH__script/hypnotoad.pid
|
||||
ExecStart=/usr/bin/carton exec hypnotoad script/lutim >> /var/log/lutim/production.log 2>&1
|
||||
ExecStop=/usr/bin/carton exec hypnotoad -s script/lutim >> /var/log/lutim/production.log 2>&1
|
||||
ExecReload=/usr/bin/carton exec hypnotoad script/lutim >> /var/log/lutim/production.log 2>&1
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
|
@ -5,7 +5,7 @@
|
|||
"en": "Self hosting images and sharing anonymous application",
|
||||
"fr": "Application d'hébergement et de partage d'images anonyme"
|
||||
},
|
||||
"version": "0.6+",
|
||||
"version": "0.6 dev",
|
||||
"url": "https://lut.im",
|
||||
"licence": "free",
|
||||
"maintainer": {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
app=lutim
|
||||
final_path=$(sudo yunohost app setting $app final_path)
|
||||
domain=$(sudo yunohost app setting $app domain)
|
||||
|
||||
codename=$(sudo yunohost app setting $app codename)
|
||||
|
||||
# The parameter $1 is the backup directory location
|
||||
# which will be compressed afterward
|
||||
|
@ -18,10 +18,15 @@ sudo cp -a $final_path/. $backup_dir/sources
|
|||
sudo cp -a /etc/yunohost/apps/$app/. $backup_dir/yunohost
|
||||
sudo cp -a /etc/nginx/conf.d/$domain.d/$app.conf $backup_dir/nginx.conf
|
||||
|
||||
|
||||
# Copie des fichiers du script init
|
||||
sudo cp -a /etc/init.d/lutim $backup_dir/init.d_lutim
|
||||
sudo cp -a /etc/default/lutim $backup_dir/default_lutim
|
||||
if [ "$codename" = "wheezy" ]
|
||||
then
|
||||
# Copie des fichiers du script init
|
||||
sudo cp -a /etc/init.d/lutim $backup_dir/init.d_lutim
|
||||
sudo cp -a /etc/default/lutim $backup_dir/default_lutim
|
||||
else
|
||||
# Copie des fichiers du script systemd
|
||||
sudo cp -a /etc/systemd/system/lutim.service $backup_dir/
|
||||
fi
|
||||
|
||||
# Copie du fichier du cron
|
||||
sudo cp -a /etc/cron.d/$app $backup_dir/cron_$app
|
||||
|
|
|
@ -87,13 +87,26 @@ sudo sed -i "s@__ENCRYPT__@$always_encrypt@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"
|
||||
|
||||
|
||||
# Mise en place des scripts init
|
||||
sudo cp ../conf/lutim.init /etc/init.d/lutim
|
||||
sudo cp ../conf/lutim.default /etc/default/lutim
|
||||
sudo chmod +x /etc/init.d/lutim
|
||||
sudo chown root:root /etc/init.d/lutim /etc/default/lutim
|
||||
sudo sed -i "s@__FINALPATH__@$final_path/@g" /etc/default/lutim
|
||||
codename=$(lsb_release -a 2>/dev/null | grep Codename | cut -f 2)
|
||||
sudo yunohost app setting $app codename -v $codename
|
||||
if [ "$codename" = "wheezy" ]
|
||||
then # On utilise le script init pour wheezy.
|
||||
# Mise en place du script init
|
||||
sudo cp ../conf/lutim.init /etc/init.d/lutim
|
||||
sudo cp ../conf/lutim.default /etc/default/lutim
|
||||
sudo chmod +x /etc/init.d/lutim
|
||||
sudo chown root: /etc/init.d/lutim /etc/default/lutim
|
||||
sudo sed -i "s@__FINALPATH__@$final_path/@g" /etc/default/lutim
|
||||
## Démarrage auto du service
|
||||
sudo update-rc.d lutim defaults
|
||||
else # Et le script systemd à partir de jessie
|
||||
# Mise en place du script systemd
|
||||
sudo cp ../conf/lutim.service /etc/systemd/system/lutim.service
|
||||
sudo chown root: /etc/systemd/system/lutim.service
|
||||
sudo sed -i "s@__FINALPATH__@$final_path/@g" /etc/systemd/system/lutim.service
|
||||
## Démarrage auto du service
|
||||
sudo systemctl enable lutim.service
|
||||
fi
|
||||
|
||||
## Mise en place des crons
|
||||
sudo cp ../conf/cron_lutim /etc/cron.d/$app
|
||||
|
@ -113,9 +126,6 @@ then
|
|||
fi
|
||||
sudo sed -i "s@__ARCHDIR__@$arch_dir@g" "$final_path/script/lutim"
|
||||
|
||||
## Démarrage auto des scripts init
|
||||
sudo update-rc.d lutim defaults
|
||||
|
||||
# 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
|
||||
|
@ -134,8 +144,9 @@ sudo ln -s /var/log/$app/production.log "$final_path/log/production.log"
|
|||
|
||||
# Configure les droits d'accès au fichiers
|
||||
sudo chown -R www-data: $final_path
|
||||
|
||||
# Start lutim
|
||||
sudo /etc/init.d/lutim start
|
||||
sudo service lutim start
|
||||
# Set right permissions on new files created at first start
|
||||
sudo chown -R www-data: "$final_path"
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ app=lutim
|
|||
|
||||
# Récupère les infos de l'application.
|
||||
domain=$(sudo yunohost app setting $app domain)
|
||||
codename=$(sudo yunohost app setting $app codename)
|
||||
|
||||
# Arrêt du service
|
||||
sudo service lutim stop
|
||||
|
@ -11,10 +12,15 @@ sudo service lutim stop
|
|||
# Retire le service du monitoring de Yunohost.
|
||||
sudo yunohost service remove lutim
|
||||
|
||||
# Suppression des fichiers init
|
||||
sudo rm -f /etc/default/lutim
|
||||
sudo rm -f /etc/init.d/lutim
|
||||
sudo update-rc.d -f lutim remove
|
||||
if [ "$codename" = "wheezy" ]
|
||||
then # Suppression des fichiers init
|
||||
sudo rm -f /etc/default/lutim
|
||||
sudo rm -f /etc/init.d/lutim
|
||||
sudo update-rc.d -f lutim remove
|
||||
else # Suppression des fichiers systemd
|
||||
sudo systemctl disable lutim.service
|
||||
sudo rm -f /etc/systemd/system/lutim.service
|
||||
fi
|
||||
|
||||
# Suppression du dossier de l'application
|
||||
sudo rm -rf /var/www/$app
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
app=lutim
|
||||
final_path=$(sudo yunohost app setting $app final_path)
|
||||
domain=$(sudo yunohost app setting $app domain)
|
||||
codename=$(sudo yunohost app setting $app codename)
|
||||
|
||||
# The parameter $1 is the uncompressed restore directory location
|
||||
backup_dir=$1/apps/$app
|
||||
|
@ -16,9 +17,15 @@ sudo cp -a $backup_dir/yunohost/. /etc/yunohost/apps/$app
|
|||
sudo cp -a $backup_dir/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
||||
|
||||
|
||||
# Restauration des fichiers du script init
|
||||
sudo cp -a $backup_dir/init.d_lutim /etc/init.d/lutim
|
||||
sudo cp -a $backup_dir/default_lutim /etc/default/lutim
|
||||
if [ "$codename" = "wheezy" ]
|
||||
then
|
||||
# Restauration des fichiers du script init
|
||||
sudo cp -a $backup_dir/init.d_lutim /etc/init.d/lutim
|
||||
sudo cp -a $backup_dir/default_lutim /etc/default/lutim
|
||||
else
|
||||
# Restauration des fichiers du script systemd
|
||||
sudo cp -a $backup_dir/lutim.service /etc/systemd/system/lutim.service
|
||||
fi
|
||||
|
||||
# Restauration du fichier du cron
|
||||
sudo cp -a $backup_dir/cron_$app /etc/cron.d/$app
|
||||
|
|
|
@ -39,13 +39,32 @@ else
|
|||
fi
|
||||
sudo sed -i "s@__ENCRYPT__@$always_encrypt@g" "$final_path/lutim.conf"
|
||||
|
||||
# Mise en place des scripts init
|
||||
sudo cp ../conf/lutim.init /etc/init.d/lutim
|
||||
sudo sed -i "s@__FINALPATH__@$final_path@g" /etc/init.d/lutim
|
||||
sudo cp ../conf/lutim.default /etc/default/lutim
|
||||
sudo chmod +x /etc/init.d/lutim
|
||||
sudo chown root:root /etc/init.d/lutim /etc/default/lutim
|
||||
sudo sed -i "s@__FINALPATH__@$final_path/@g" /etc/default/lutim
|
||||
codename=$(lsb_release -a 2>/dev/null | grep Codename | cut -f 2)
|
||||
sudo yunohost app setting $app codename -v $codename
|
||||
if [ "$codename" = "wheezy" ]
|
||||
then # On utilise le script init pour wheezy.
|
||||
# Mise en place du script init
|
||||
sudo cp ../conf/lutim.init /etc/init.d/lutim
|
||||
sudo cp ../conf/lutim.default /etc/default/lutim
|
||||
sudo chmod +x /etc/init.d/lutim
|
||||
sudo chown root: /etc/init.d/lutim /etc/default/lutim
|
||||
sudo sed -i "s@__FINALPATH__@$final_path/@g" /etc/default/lutim
|
||||
## Démarrage auto du service
|
||||
sudo update-rc.d lutim defaults
|
||||
else # Et le script systemd à partir de jessie
|
||||
# Mise en place du script systemd
|
||||
sudo cp ../conf/lutim.service /etc/systemd/system/lutim.service
|
||||
sudo chown root:root /etc/systemd/system/lutim.service
|
||||
sudo sed -i "s@__FINALPATH__@$final_path/@g" /etc/systemd/system/lutim.service
|
||||
## Démarrage auto du service
|
||||
sudo systemctl enable lutim.service
|
||||
if [ -e /etc/init.d/lutim ]
|
||||
then # Supprime le script init.d si il existe.
|
||||
sudo rm -f /etc/default/lutim
|
||||
sudo rm -f /etc/init.d/lutim
|
||||
sudo update-rc.d -f lutim remove
|
||||
fi
|
||||
fi
|
||||
|
||||
## Mise en place des crons
|
||||
sudo cp ../conf/cron_lutim /etc/cron.d/$app
|
||||
|
@ -65,7 +84,7 @@ fi
|
|||
# Configure les droits d'accès au fichiers
|
||||
sudo chown -R www-data: $final_path
|
||||
# Restart lutim
|
||||
sudo /etc/init.d/lutim restart
|
||||
sudo service lutim restart
|
||||
|
||||
|
||||
# Recharge la configuration Nginx
|
||||
|
|
Loading…
Add table
Reference in a new issue