1
0
Fork 0
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:
zamentur 2014-12-07 23:11:39 +01:00
parent bb696461c0
commit 07a28bcac3
4 changed files with 44 additions and 14 deletions

View file

@ -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"
EPLITE_DIR="/usr/local/bin"
EPLITE_BIN="ethercalc"
USER="www-data"
GROUP="www-data"
USER="$app"
GROUP="$app"
DESC="EtherCalc"
NAME="$app"
export NODE_ENV=production
set -e
. /lib/lsb/init-functions

10
conf/logrotate Normal file
View file

@ -0,0 +1,10 @@
YNH_LOGFILE
{
weekly
missingok
rotate 12
notifempty
compress
delaycompress
copytruncate
}

View file

@ -16,17 +16,30 @@ if [[ ! $? -eq 0 ]]; then
exit 1
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 port -v $port
# Remove trailing "/" for next commands
path=${path%/}
# Install dependances
echo "Install dependencies..."
sudo apt-get update
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@YUNOLOG@$app_id_forked@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
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
sudo touch $logfile
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@ALIASTOCHANGE@$final_path/@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
fi
# Reload Nginx and regenerate SSOwat conf
echo "Reloading Nginx..."
sudo service nginx reload
if [ "$is_public" = "Yes" ];
then
sudo yunohost app setting ethercalc skipped_uris -v "/"
fi
sudo service $app_id_forked stop
sudo service $app_id_forked start
sudo yunohost app ssowatconf

View file

@ -7,9 +7,11 @@ name+="calc"
domain=$(sudo yunohost app setting $app domain)
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 service $app stop
sudo rm /etc/init.d/$app
sudo yunohost service remove $app
sudo userdel --remove $app