mirror of
https://github.com/YunoHost-Apps/ethercalc_ynh.git
synced 2024-09-03 18:26:36 +02:00
[enh] Isolate npm installation
[enh] Set up logrotate [enh] Add echo to follow installation progress
This commit is contained in:
parent
bb696461c0
commit
07a28bcac3
4 changed files with 44 additions and 14 deletions
|
@ -14,11 +14,11 @@ PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/node/bin
|
||||||
LOGFILE="/var/log/ethercalc/YUNOLOG.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="$app"
|
||||||
GROUP="www-data"
|
GROUP="$app"
|
||||||
DESC="EtherCalc"
|
DESC="EtherCalc"
|
||||||
NAME="$app"
|
NAME="$app"
|
||||||
|
export NODE_ENV=production
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
. /lib/lsb/init-functions
|
. /lib/lsb/init-functions
|
||||||
|
|
10
conf/logrotate
Normal file
10
conf/logrotate
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
YNH_LOGFILE
|
||||||
|
{
|
||||||
|
weekly
|
||||||
|
missingok
|
||||||
|
rotate 12
|
||||||
|
notifempty
|
||||||
|
compress
|
||||||
|
delaycompress
|
||||||
|
copytruncate
|
||||||
|
}
|
|
@ -16,17 +16,30 @@ if [[ ! $? -eq 0 ]]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Save specific settings
|
echo "Register configuration..."
|
||||||
sudo yunohost app setting $app_id_forked is_public -v $is_public
|
sudo yunohost app setting $app_id_forked is_public -v $is_public
|
||||||
|
sudo yunohost app setting $app_id_forked port -v $port
|
||||||
|
|
||||||
# Remove trailing "/" for next commands
|
# Remove trailing "/" for next commands
|
||||||
path=${path%/}
|
path=${path%/}
|
||||||
|
|
||||||
# Install dependances
|
echo "Install dependencies..."
|
||||||
|
sudo apt-get update
|
||||||
sudo apt-get install nodejs-legacy npm redis-server -y
|
sudo apt-get install nodejs-legacy npm redis-server -y
|
||||||
sudo npm i -g $app_id
|
|
||||||
|
|
||||||
# Copy files to the right place
|
echo "Installing EtherCalc with NPM..."
|
||||||
|
final_path=/var/www/$app_id_forked
|
||||||
|
sudo mkdir -p $final_path
|
||||||
|
sudo useradd -d $final_path $app_id_forked
|
||||||
|
su --shell /bin/bash --command "cd $final_path/ && npm install --production $app_id" $app_id_forked
|
||||||
|
|
||||||
|
echo "Cleaning up install tree..."
|
||||||
|
sudo rm -rf $final_path/.npm
|
||||||
|
find $final_path -type d | grep "test$" | xargs sudo rm -rf
|
||||||
|
find $final_path -type d | grep "tests$" | xargs sudo rm -rf
|
||||||
|
|
||||||
|
echo "Setting up init script..."
|
||||||
|
logfile=/var/log/$app_id/$app_id_forked.log
|
||||||
sed -i "s@YUNOPORT@$port@g" ../conf/$app_id
|
sed -i "s@YUNOPORT@$port@g" ../conf/$app_id
|
||||||
sed -i "s@YUNOLOG@$app_id_forked@g" ../conf/$app_id
|
sed -i "s@YUNOLOG@$app_id_forked@g" ../conf/$app_id
|
||||||
sed -i "s@YUNOPATH@$path@g" ../conf/$app_id
|
sed -i "s@YUNOPATH@$path@g" ../conf/$app_id
|
||||||
|
@ -36,10 +49,17 @@ sudo update-rc.d $app_id_forked defaults
|
||||||
if [ ! -d "/var/log/$app_id/" ]; then
|
if [ ! -d "/var/log/$app_id/" ]; then
|
||||||
sudo mkdir /var/log/$app_id/
|
sudo mkdir /var/log/$app_id/
|
||||||
fi
|
fi
|
||||||
sudo touch /var/log/$app_id/$app_id_forked.log
|
sudo touch $logfile
|
||||||
sudo chown www-data /var/log/$app_id/$app_id_forked.log
|
sudo chown $app_id_forked $logfile
|
||||||
|
sudo service $app_id_forked stop
|
||||||
|
sudo service $app_id_forked start
|
||||||
|
sudo yunohost service add $app_id_forked -l $logfile
|
||||||
|
|
||||||
# Modify Nginx configuration file and copy it to Nginx conf directory
|
echo "Setting up logrotate configuration..."
|
||||||
|
sed -i "s@YNH_LOGFILE@$logfile@g" ../conf/logrotate
|
||||||
|
sudo cp ../conf/logrotate /etc/logrotate.d/$app_id_forked
|
||||||
|
|
||||||
|
echo "Nginx configuration ..."
|
||||||
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*
|
sed -i "s@YUNOPORT@$port@g" ../conf/nginx.conf*
|
||||||
|
@ -50,12 +70,10 @@ else
|
||||||
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app_id_forked.conf
|
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app_id_forked.conf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Reload Nginx and regenerate SSOwat conf
|
echo "Reloading Nginx..."
|
||||||
sudo service nginx reload
|
sudo service nginx reload
|
||||||
if [ "$is_public" = "Yes" ];
|
if [ "$is_public" = "Yes" ];
|
||||||
then
|
then
|
||||||
sudo yunohost app setting ethercalc skipped_uris -v "/"
|
sudo yunohost app setting ethercalc skipped_uris -v "/"
|
||||||
fi
|
fi
|
||||||
sudo service $app_id_forked stop
|
|
||||||
sudo service $app_id_forked start
|
|
||||||
sudo yunohost app ssowatconf
|
sudo yunohost app ssowatconf
|
||||||
|
|
|
@ -7,9 +7,11 @@ 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/$name/$app
|
sudo rm -Rf /var/log/$name/$app.log*
|
||||||
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
|
||||||
|
sudo yunohost service remove $app
|
||||||
|
|
||||||
|
sudo userdel --remove $app
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue