1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/ethercalc_ynh.git synced 2024-09-03 18:26:36 +02:00

- add multisite feature

This commit is contained in:
zamentur 2014-09-08 00:23:35 +02:00
parent 80b8d3875e
commit 6c47b6eb16
6 changed files with 35 additions and 23 deletions

View file

@ -9,9 +9,9 @@
# Short-Description: starts ethercalc # Short-Description: starts ethercalc
# Description: starts ethercalc using start-stop-daemon # Description: starts ethercalc using start-stop-daemon
### END INIT INFO ### END INIT INFO
app="ethercalc"
PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/node/bin" PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/node/bin"
LOGFILE="/var/log/$app/$app.log" LOGFILE="/var/log/ethercalc/YUNOLOG.log"
EPLITE_DIR="/usr/local/bin" EPLITE_DIR="/usr/local/bin"
EPLITE_BIN="ethercalc" EPLITE_BIN="ethercalc"
USER="www-data" USER="www-data"
@ -25,8 +25,8 @@ set -e
start() { start() {
echo "Starting $DESC... " echo "Starting $DESC... "
PORT=YUNOPORT
start-stop-daemon --start --chuid "$USER:$GROUP" --background --make-pidfile --pidfile /var/run/$NAME.pid --exec $EPLITE_DIR/$EPLITE_BIN -- $LOGFILE || true start-stop-daemon --start --chuid "$USER:$GROUP" --background --make-pidfile --pidfile /var/run/$NAME.pid --exec $EPLITE_DIR/$EPLITE_BIN -- $LOGFILE --basepath YUNOPATH || true
echo "done" echo "done"
} }

View file

@ -1,6 +1,6 @@
location PATHTOCHANGE/ { location PATHTOCHANGE/ {
rewrite ^PATHTOCHANGE$ PATHTOCHANGE/ permanent; rewrite ^PATHTOCHANGE$ PATHTOCHANGE/ permanent;
proxy_pass http://localhost:8000/; proxy_pass http://localhost:YUNOPORT/;
proxy_set_header Host $host; proxy_set_header Host $host;
proxy_buffering off; proxy_buffering off;
} }

View file

@ -1,5 +1,5 @@
location / { location / {
proxy_pass http://localhost:8000/; proxy_pass http://localhost:YUNOPORT/;
proxy_set_header Host $host; proxy_set_header Host $host;
# be careful, this line doesn't override any proxy_buffering on set in a conf.d/file.conf # be careful, this line doesn't override any proxy_buffering on set in a conf.d/file.conf
proxy_buffering off; proxy_buffering off;

View file

@ -9,7 +9,7 @@
"email": "valentin@grimaud.me", "email": "valentin@grimaud.me",
"url": "https://ethercalc.net/" "url": "https://ethercalc.net/"
}, },
"multi_instance": "false", "multi_instance": "true",
"arguments": { "arguments": {
"install" : [ "install" : [
{ {

View file

@ -1,51 +1,61 @@
#!/bin/bash #!/bin/bash
app="ethercalc" app_id_forked="ethercalc"
app_id="ether"
app_id+="calc"
instance_number=$(echo $app_id_forked | sed 's/[^0-9]//g')
# Retrieve arguments # Retrieve arguments
domain=$1 domain=$1
path=$2 path=$2
is_public=$3 is_public=$3
port=$((instance_number+8000))
# Check domain/path availability # Check domain/path availability
sudo yunohost app checkurl $domain$path -a $app sudo yunohost app checkurl $domain$path -a $app_id_forked
if [[ ! $? -eq 0 ]]; then if [[ ! $? -eq 0 ]]; then
exit 1 exit 1
fi fi
# Save specific settings # Save specific settings
sudo yunohost app setting $app is_public -v $is_public sudo yunohost app setting $app_id_forked is_public -v $is_public
# Remove trailing "/" for next commands # Remove trailing "/" for next commands
path=${path%/} path=${path%/}
# Install dependances # Install dependances
sudo apt-get install nodejs-legacy npm redis-server -y sudo apt-get install nodejs-legacy npm redis-server -y
sudo npm i -g ethercalc #sudo npm i -g $app_id
# Copy files to the right place # Copy files to the right place
sudo cp ../conf/$app /etc/init.d/ sed -i "s@YUNOPORT@$port@g" ../conf/$app_id
sudo chmod +x /etc/init.d/$app sed -i "s@YUNOLOG@$app_id_forked@g" ../conf/$app_id
sudo update-rc.d $app defaults sed -i "s@YUNOPATH@$path@g" ../conf/$app_id
sudo mkdir /var/log/$app/ sudo cp ../conf/$app_id /etc/init.d/$app_id_forked
sudo touch /var/log/$app/$app.log sudo chmod +x /etc/init.d/$app_id_forked
sudo chown www-data /var/log/$app/$app.log sudo update-rc.d $app_id_forked defaults
if [ ! -d "/var/log/$app_id/" ]; then
sudo mkdir /var/log/$app_id/
fi
sudo touch /var/log/$app_id/$app_id_forked.log
sudo chown www-data /var/log/$app_id/$app_id_forked.log
# Modify Nginx configuration file and copy it to Nginx conf directory # Modify Nginx configuration file and copy it to Nginx conf directory
sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf* sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf*
sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf* sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf*
sed -i "s@YUNOPORT@$port@g" ../conf/nginx.conf*
if [ "$path" = "" ]; if [ "$path" = "" ];
then then
sudo cp ../conf/nginx.conf-nosub /etc/nginx/conf.d/$domain.d/$app.conf sudo cp ../conf/nginx.conf-nosub /etc/nginx/conf.d/$domain.d/$app_id_forked.conf
else else
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app_id_forked.conf
fi fi
# Reload Nginx and regenerate SSOwat conf # Reload Nginx and regenerate SSOwat conf
sudo service nginx reload sudo service nginx reload
if [ "$is_public" = "Yes" ]; if [ "$is_public" = "Yes" ];
then then
sudo yunohost app setting $app skipped_uris -v "/" sudo yunohost app setting ethercalc skipped_regex -v "$final_path/.*"
fi fi
sudo service $app_id_forked stop
sudo service $app_id_forked start
sudo yunohost app ssowatconf sudo yunohost app ssowatconf
sudo service $app start

View file

@ -1,11 +1,13 @@
#!/bin/bash #!/bin/bash
app="ethercalc" app="ethercalc"
name="ether"
name+="calc"
domain=$(sudo yunohost app setting $app domain) domain=$(sudo yunohost app setting $app domain)
sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf
sudo rm -Rf /var/log/$app/ sudo rm -Rf /var/log/$name/$app
sudo update-rc.d $app remove sudo update-rc.d $app remove
sudo service $app stop sudo service $app stop
sudo rm /etc/init.d/$app sudo rm /etc/init.d/$app