mirror of
https://github.com/YunoHost-Apps/ethercalc_ynh.git
synced 2024-09-03 18:26:36 +02:00
Install script (support only one instance)
This commit is contained in:
commit
80b8d3875e
8 changed files with 210 additions and 0 deletions
8
README.md
Normal file
8
README.md
Normal file
|
@ -0,0 +1,8 @@
|
|||
ethercalc_ynh
|
||||
===============
|
||||
|
||||
EtherCalc for YunoHost
|
||||
|
||||
LimeSurvey is an online web spreadsheet.
|
||||
|
||||
https://ethercalc.net/
|
79
conf/ethercalc
Normal file
79
conf/ethercalc
Normal file
|
@ -0,0 +1,79 @@
|
|||
#!/bin/sh
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: ethercalc
|
||||
# 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 ethercalc
|
||||
# Description: starts ethercalc using start-stop-daemon
|
||||
### END INIT INFO
|
||||
app="ethercalc"
|
||||
PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/node/bin"
|
||||
LOGFILE="/var/log/$app/$app.log"
|
||||
EPLITE_DIR="/usr/local/bin"
|
||||
EPLITE_BIN="ethercalc"
|
||||
USER="www-data"
|
||||
GROUP="www-data"
|
||||
DESC="EtherCalc"
|
||||
NAME="$app"
|
||||
|
||||
set -e
|
||||
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
start() {
|
||||
echo "Starting $DESC... "
|
||||
|
||||
start-stop-daemon --start --chuid "$USER:$GROUP" --background --make-pidfile --pidfile /var/run/$NAME.pid --exec $EPLITE_DIR/$EPLITE_BIN -- $LOGFILE || true
|
||||
echo "done"
|
||||
}
|
||||
|
||||
#We need this function to ensure the whole process tree will be killed
|
||||
killtree() {
|
||||
local _pid=$1
|
||||
local _sig=${2-TERM}
|
||||
for _child in $(ps -o pid --no-headers --ppid ${_pid}); do
|
||||
killtree ${_child} ${_sig}
|
||||
done
|
||||
kill -${_sig} ${_pid}
|
||||
}
|
||||
|
||||
stop() {
|
||||
echo "Stopping $DESC... "
|
||||
if test -f /var/run/$NAME.pid; then
|
||||
while test -d /proc/$(cat /var/run/$NAME.pid); do
|
||||
killtree $(cat /var/run/$NAME.pid) 15
|
||||
sleep 0.5
|
||||
done
|
||||
rm /var/run/$NAME.pid
|
||||
fi
|
||||
echo "done"
|
||||
}
|
||||
|
||||
status() {
|
||||
status_of_proc -p /var/run/$NAME.pid "" "$app" && exit 0 || exit $?
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
restart)
|
||||
stop
|
||||
start
|
||||
;;
|
||||
status)
|
||||
status
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $NAME {start|stop|restart|status}" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
6
conf/nginx.conf
Normal file
6
conf/nginx.conf
Normal file
|
@ -0,0 +1,6 @@
|
|||
location PATHTOCHANGE/ {
|
||||
rewrite ^PATHTOCHANGE$ PATHTOCHANGE/ permanent;
|
||||
proxy_pass http://localhost:8000/;
|
||||
proxy_set_header Host $host;
|
||||
proxy_buffering off;
|
||||
}
|
6
conf/nginx.conf-nosub
Normal file
6
conf/nginx.conf-nosub
Normal file
|
@ -0,0 +1,6 @@
|
|||
location / {
|
||||
proxy_pass http://localhost:8000/;
|
||||
proxy_set_header Host $host;
|
||||
# be careful, this line doesn't override any proxy_buffering on set in a conf.d/file.conf
|
||||
proxy_buffering off;
|
||||
}
|
44
manifest.json
Normal file
44
manifest.json
Normal file
|
@ -0,0 +1,44 @@
|
|||
{
|
||||
"name": "EtherCalc",
|
||||
"id": "ethercalc",
|
||||
"description": {
|
||||
"en": "online web spreadsheet editor providing collaborative editing in really real-time"
|
||||
},
|
||||
"developer": {
|
||||
"name": "zamentur",
|
||||
"email": "valentin@grimaud.me",
|
||||
"url": "https://ethercalc.net/"
|
||||
},
|
||||
"multi_instance": "false",
|
||||
"arguments": {
|
||||
"install" : [
|
||||
{
|
||||
"name": "domain",
|
||||
"ask": {
|
||||
"en": "Choose a domain for EtherCalc"
|
||||
},
|
||||
"example": "domain.org"
|
||||
},
|
||||
{
|
||||
"name": "path",
|
||||
"ask": {
|
||||
"en": "Choose a path for EtherCalc"
|
||||
},
|
||||
"example": "/calc",
|
||||
"default": "/calc"
|
||||
},
|
||||
{
|
||||
"name": "public_site",
|
||||
"ask": {
|
||||
"en": "Is it a public EtherCalc ?"
|
||||
},
|
||||
"choices": ["Yes", "No"],
|
||||
"default": "Yes"
|
||||
}
|
||||
|
||||
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
51
scripts/install
Normal file
51
scripts/install
Normal file
|
@ -0,0 +1,51 @@
|
|||
#!/bin/bash
|
||||
|
||||
app="ethercalc"
|
||||
|
||||
# Retrieve arguments
|
||||
domain=$1
|
||||
path=$2
|
||||
is_public=$3
|
||||
|
||||
# Check domain/path availability
|
||||
sudo yunohost app checkurl $domain$path -a $app
|
||||
if [[ ! $? -eq 0 ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Save specific settings
|
||||
sudo yunohost app setting $app is_public -v $is_public
|
||||
|
||||
# Remove trailing "/" for next commands
|
||||
path=${path%/}
|
||||
|
||||
# Install dependances
|
||||
sudo apt-get install nodejs-legacy npm redis-server -y
|
||||
sudo npm i -g ethercalc
|
||||
|
||||
# Copy files to the right place
|
||||
sudo cp ../conf/$app /etc/init.d/
|
||||
sudo chmod +x /etc/init.d/$app
|
||||
sudo update-rc.d $app defaults
|
||||
sudo mkdir /var/log/$app/
|
||||
sudo touch /var/log/$app/$app.log
|
||||
sudo chown www-data /var/log/$app/$app.log
|
||||
|
||||
# Modify Nginx configuration file and copy it to Nginx conf directory
|
||||
sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf*
|
||||
sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf*
|
||||
if [ "$path" = "" ];
|
||||
then
|
||||
sudo cp ../conf/nginx.conf-nosub /etc/nginx/conf.d/$domain.d/$app.conf
|
||||
else
|
||||
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
||||
fi
|
||||
|
||||
# Reload Nginx and regenerate SSOwat conf
|
||||
sudo service nginx reload
|
||||
if [ "$is_public" = "Yes" ];
|
||||
then
|
||||
sudo yunohost app setting $app skipped_uris -v "/"
|
||||
fi
|
||||
sudo yunohost app ssowatconf
|
||||
sudo service $app start
|
13
scripts/remove
Normal file
13
scripts/remove
Normal file
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
|
||||
app="ethercalc"
|
||||
|
||||
domain=$(sudo yunohost app setting $app domain)
|
||||
|
||||
sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf
|
||||
sudo rm -Rf /var/log/$app/
|
||||
sudo update-rc.d $app remove
|
||||
sudo service $app stop
|
||||
sudo rm /etc/init.d/$app
|
||||
|
||||
|
3
scripts/upgrade
Normal file
3
scripts/upgrade
Normal file
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
|
||||
#TODO
|
Loading…
Add table
Reference in a new issue