mirror of
https://github.com/YunoHost-Apps/lutim_ynh.git
synced 2024-09-03 19:36:24 +02:00
Merge branch 'master' of https://github.com/maniackcrudelis/lutim_ynh
Conflicts: conf/lutim.init manifest.json scripts/install scripts/remove
This commit is contained in:
commit
dc39b5e6e0
4 changed files with 0 additions and 378 deletions
193
conf/lutim.init
193
conf/lutim.init
|
@ -1,193 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
# vim: set ts=4 sw=4 sts=4 tw=0:
|
|
||||||
# vim: set expandtab:
|
|
||||||
|
|
||||||
### BEGIN INIT INFO
|
|
||||||
# Provides: lutim
|
|
||||||
# Required-Start: $local_fs $remote_fs $network $syslog
|
|
||||||
# Required-Stop: $local_fs $remote_fs $network $syslog
|
|
||||||
# Default-Start: 2 3 4 5
|
|
||||||
# Default-Stop: 0 1 6
|
|
||||||
# Short-Description: starts lutim with hypnotoad
|
|
||||||
# Description: starts lutim with hypnotoad
|
|
||||||
### END INIT INFO
|
|
||||||
|
|
||||||
|
|
||||||
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
|
||||||
DAEMON=script/lutim
|
|
||||||
NAME=lutim
|
|
||||||
DESC=lutim
|
|
||||||
LUTIM_DIR=__FINALPATH__
|
|
||||||
|
|
||||||
if [ -f "/etc/default/lutim" ]
|
|
||||||
then
|
|
||||||
. /etc/default/lutim
|
|
||||||
if [ -z $LDIR ]
|
|
||||||
then
|
|
||||||
echo "LDIR variable is empty, please fill it in /etc/default/lutim"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "Missing /etc/default/lutim file"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -f "$LDIR$DAEMON" ]
|
|
||||||
then
|
|
||||||
echo "Missing $LDIR$DAEMON file"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
. /lib/lsb/init-functions
|
|
||||||
|
|
||||||
do_start()
|
|
||||||
{
|
|
||||||
# Return
|
|
||||||
# 0 if daemon has been started
|
|
||||||
# 1 if daemon was already running
|
|
||||||
# 2 if daemon could not be started
|
|
||||||
|
|
||||||
cd $LDIR
|
|
||||||
carton exec hypnotoad $DAEMON >> $LUTIM_DIR/log/production.log 2>&1
|
|
||||||
return "$?"
|
|
||||||
}
|
|
||||||
|
|
||||||
do_stop()
|
|
||||||
{
|
|
||||||
# Return
|
|
||||||
# 0 if daemon has been stopped
|
|
||||||
# 1 if daemon was already stopped
|
|
||||||
# 2 if daemon could not be stopped
|
|
||||||
# other if a failure occurred
|
|
||||||
|
|
||||||
cd $LDIR
|
|
||||||
carton exec hypnotoad -s $DAEMON >> $LUTIM_DIR/log/production.log 2>&1
|
|
||||||
|
|
||||||
return "$?"
|
|
||||||
}
|
|
||||||
|
|
||||||
do_status()
|
|
||||||
{
|
|
||||||
cd $LDIR
|
|
||||||
if [ -f "script/hypnotoad.pid" ]
|
|
||||||
then
|
|
||||||
pgrep -lf $DAEMON >/dev/null 2>&1
|
|
||||||
if [ "$?" = "0" ]; then
|
|
||||||
log_progress_msg "$NAME is running"
|
|
||||||
else
|
|
||||||
log_progress_msg "$NAME is NOT running"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
log_progress_msg "$NAME is NOT running"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
case "$1" in
|
|
||||||
start)
|
|
||||||
log_daemon_msg "Starting $NAME"
|
|
||||||
cd $LDIR
|
|
||||||
if [ -f "script/hypnotoad.pid" ]
|
|
||||||
then
|
|
||||||
pgrep -lf $DAEMON >/dev/null 2>&1
|
|
||||||
if [ "$?" = "0" ]
|
|
||||||
then
|
|
||||||
log_progress_msg "$NAME is already running. Unable to start."
|
|
||||||
log_end_msg 1;
|
|
||||||
else
|
|
||||||
do_start
|
|
||||||
case "$?" in
|
|
||||||
0|1)
|
|
||||||
log_progress_msg "done"
|
|
||||||
log_end_msg 0
|
|
||||||
;;
|
|
||||||
2)
|
|
||||||
log_progress_msg "failed"
|
|
||||||
log_end_msg 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
do_start
|
|
||||||
case "$?" in
|
|
||||||
0|1)
|
|
||||||
log_progress_msg "done"
|
|
||||||
log_end_msg 0
|
|
||||||
;;
|
|
||||||
2)
|
|
||||||
log_progress_msg "failed"
|
|
||||||
log_end_msg 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
stop)
|
|
||||||
log_daemon_msg "Stopping $NAME"
|
|
||||||
cd $LDIR
|
|
||||||
if [ -f "script/hypnotoad.pid" ]
|
|
||||||
then
|
|
||||||
pgrep -lf $DAEMON >/dev/null 2>&1
|
|
||||||
if [ "$?" = "0" ]; then
|
|
||||||
do_stop
|
|
||||||
case "$?" in
|
|
||||||
0|1)
|
|
||||||
log_progress_msg "done"
|
|
||||||
log_end_msg 0
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
log_progress_msg "failed"
|
|
||||||
log_end_msg 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
else
|
|
||||||
log_progress_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_end_msg 1
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
status)
|
|
||||||
log_daemon_msg "Checking $NAME status"
|
|
||||||
do_status
|
|
||||||
log_end_msg 0
|
|
||||||
;;
|
|
||||||
reload)
|
|
||||||
log_daemon_msg "Reloading $NAME"
|
|
||||||
do_start
|
|
||||||
case "$?" in
|
|
||||||
0|1)
|
|
||||||
log_progress_msg "done"
|
|
||||||
log_end_msg 0
|
|
||||||
;;
|
|
||||||
2)
|
|
||||||
log_progress_msg "failed"
|
|
||||||
log_end_msg 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
restart)
|
|
||||||
log_daemon_msg "Restarting $NAME"
|
|
||||||
do_stop
|
|
||||||
sleep 1
|
|
||||||
do_start
|
|
||||||
case "$?" in
|
|
||||||
0|1)
|
|
||||||
log_progress_msg "done"
|
|
||||||
log_end_msg 0
|
|
||||||
;;
|
|
||||||
2)
|
|
||||||
log_progress_msg "failed";
|
|
||||||
log_end_msg 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Usage: $0 {start|stop|status|reload|restart}" >&2
|
|
||||||
exit 3
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
exit 0
|
|
|
@ -1,55 +0,0 @@
|
||||||
{
|
|
||||||
"name": "Lutim",
|
|
||||||
"id": "lutim",
|
|
||||||
"description": {
|
|
||||||
"en": "Images self hosting application",
|
|
||||||
"fr": "Application d'upload d'images"
|
|
||||||
},
|
|
||||||
"version": "0.6",
|
|
||||||
"url": "https://lut.im",
|
|
||||||
"maintainer": {
|
|
||||||
"name": "Maniack Crudelis et matlink",
|
|
||||||
"email": "maniackc_dev@crudelis.fr matlink@matlink.fr"
|
|
||||||
},
|
|
||||||
"multi_instance": "false",
|
|
||||||
"arguments": {
|
|
||||||
"install" : [
|
|
||||||
{
|
|
||||||
"name": "domain",
|
|
||||||
"ask": {
|
|
||||||
"en": "Choose a domain for Lutim",
|
|
||||||
"fr": "Choisissez un domaine pour Lutim"
|
|
||||||
},
|
|
||||||
"example": "domain.org",
|
|
||||||
"default": "crudelis-test.fr"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "path",
|
|
||||||
"ask": {
|
|
||||||
"en": "Choose a path for Lutim",
|
|
||||||
"fr": "Choisissez un chemin pour Lutim"
|
|
||||||
},
|
|
||||||
"example": "/lutim",
|
|
||||||
"default": "/lutim"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "admin",
|
|
||||||
"ask": {
|
|
||||||
"en": "Choose the Lutim administrator (must be an existing YunoHost user)",
|
|
||||||
"fr": "Choisissez un administrateur Lutim (doit être un utilisateur YunoHost)"
|
|
||||||
},
|
|
||||||
"example": "john",
|
|
||||||
"default": "mcrudelis"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "is_public",
|
|
||||||
"ask": {
|
|
||||||
"en": "Uploading images is it public?",
|
|
||||||
"fr": "L'upload des images est-il public ?"
|
|
||||||
},
|
|
||||||
"choices": ["Yes", "No"],
|
|
||||||
"default": "No"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
118
scripts/install
118
scripts/install
|
@ -1,118 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Retrieve arguments
|
|
||||||
domain=$1
|
|
||||||
path=$2
|
|
||||||
admin=$3
|
|
||||||
is_public=$4
|
|
||||||
app=lutim
|
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
# Check domain/path availability
|
|
||||||
sudo yunohost app checkurl $domain$path -a $app
|
|
||||||
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/$app
|
|
||||||
if [ -e "$final_path" ]
|
|
||||||
then
|
|
||||||
echo "This path already contains a folder"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Add settings to YunoHost
|
|
||||||
sudo yunohost app setting $app admin -v $admin
|
|
||||||
sudo yunohost app setting $app domain -v $domain
|
|
||||||
sudo yunohost app setting $app is_public -v $is_public
|
|
||||||
|
|
||||||
|
|
||||||
# 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
|
|
||||||
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
|
||||||
|
|
||||||
# Installation du module perl carton
|
|
||||||
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
|
|
||||||
|
|
||||||
# Installation de perlmagick, interface perl pour imagemagick
|
|
||||||
sudo apt-get install perlmagick -qy
|
|
||||||
|
|
||||||
## Copie et configuration du fichier de conf.
|
|
||||||
sudo cp ../conf/lutim.conf.template $final_path/lutim.conf
|
|
||||||
sudo sed -i "s@__DOMAIN__@$domain@g" $final_path/lutim.conf
|
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
## Mise en place des crons
|
|
||||||
sudo cp ../conf/cron_lutim /etc/cron.d/$app
|
|
||||||
sudo sed -i "s@__FINALPATH__@$final_path/@g" /etc/cron.d/$app
|
|
||||||
|
|
||||||
# Installation de lutim via carton
|
|
||||||
cd $final_path
|
|
||||||
sudo carton install
|
|
||||||
|
|
||||||
## Démarrage auto des scripts init
|
|
||||||
sudo update-rc.d lutim defaults
|
|
||||||
# sudo update-rc.d -f lutim remove
|
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
# Make app public or private
|
|
||||||
sudo yunohost app setting $app skipped_uris -v "/"
|
|
||||||
if [ "$is_public" = "No" ];
|
|
||||||
then # Si l'app est privée, seul le visionnage des images est public
|
|
||||||
sudo yunohost app setting $app protected_regex -v "/stats$","/manifest.webapp$","/$","/d/.*$","/m/.*$"
|
|
||||||
# sudo yunohost app setting $app skipped_regex -v "$domain/$path/[0-9A-Za-z]{8}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Set right permissions
|
|
||||||
sudo chown -R www-data: $final_path
|
|
||||||
# Start lutim
|
|
||||||
sudo /etc/init.d/lutim start
|
|
||||||
# Set right permissions on new files created at first start
|
|
||||||
sudo chown -R www-data: $final_path
|
|
||||||
|
|
||||||
# Reload Nginx and regenerate SSOwat conf
|
|
||||||
sudo service nginx reload
|
|
||||||
sudo yunohost app ssowatconf
|
|
|
@ -1,12 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
app=lutim
|
|
||||||
|
|
||||||
domain=$(sudo yunohost app setting $app domain)
|
|
||||||
final_path=$(sudo yunohost app setting $app final_path)
|
|
||||||
sudo service lutim stop
|
|
||||||
sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf
|
|
||||||
# sudo rm -rf $final_path
|
|
||||||
sudo rm -rf /var/www/lutim
|
|
||||||
sudo rm -f /etc/default/lutim
|
|
||||||
sudo rm -f /etc/init.d/lutim
|
|
Loading…
Add table
Reference in a new issue