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

[fix] Init script broken

This commit is contained in:
zamentur 2014-12-07 23:24:59 +01:00
parent 07a28bcac3
commit 15cfa1504e
2 changed files with 33 additions and 29 deletions

View file

@ -14,10 +14,10 @@ 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="$app" USER="YUNOAPP"
GROUP="$app" GROUP="YUNOAPP"
DESC="EtherCalc" DESC="EtherCalc"
NAME="$app" NAME="YUNOAPP"
export NODE_ENV=production export NODE_ENV=production
set -e set -e

View file

@ -1,9 +1,9 @@
#!/bin/bash #!/bin/bash
app_id_forked="ethercalc" app="ethercalc"
app_id="ether" name="ether"
app_id+="calc" name+="calc"
instance_number=$(echo $app_id_forked | sed 's/[^0-9]//g') instance_number=$(echo $app | sed 's/[^0-9]//g')
# Retrieve arguments # Retrieve arguments
domain=$1 domain=$1
path=$2 path=$2
@ -11,14 +11,14 @@ is_public=$3
port=$((instance_number+8000)) port=$((instance_number+8000))
# Check domain/path availability # Check domain/path availability
sudo yunohost app checkurl $domain$path -a $app_id_forked sudo yunohost app checkurl $domain$path -a $app
if [[ ! $? -eq 0 ]]; then if [[ ! $? -eq 0 ]]; then
exit 1 exit 1
fi fi
echo "Register configuration..." echo "Register configuration..."
sudo yunohost app setting $app_id_forked is_public -v $is_public sudo yunohost app setting $app is_public -v $is_public
sudo yunohost app setting $app_id_forked port -v $port sudo yunohost app setting $app port -v $port
# Remove trailing "/" for next commands # Remove trailing "/" for next commands
path=${path%/} path=${path%/}
@ -28,46 +28,50 @@ sudo apt-get update
sudo apt-get install nodejs-legacy npm redis-server -y sudo apt-get install nodejs-legacy npm redis-server -y
echo "Installing EtherCalc with NPM..." echo "Installing EtherCalc with NPM..."
final_path=/var/www/$app_id_forked final_path=/var/www/$app
sudo mkdir -p $final_path sudo mkdir -p $final_path
sudo useradd -d $final_path $app_id_forked sudo useradd -d $final_path $app
su --shell /bin/bash --command "cd $final_path/ && npm install --production $app_id" $app_id_forked su --shell /bin/bash --command "cd $final_path/ && npm install --production $name" $app
echo "Cleaning up install tree..." echo "Cleaning up install tree..."
sudo rm -rf $final_path/.npm sudo rm -rf $final_path/.npm
find $final_path -type d | grep "test$" | xargs sudo rm -rf find $final_path -type d | grep "test$" | xargs sudo rm -rf
find $final_path -type d | grep "tests$" | xargs sudo rm -rf find $final_path -type d | grep "tests$" | xargs sudo rm -rf
echo "Setting up permissions"
sudo chown -R ghostblog: $final_path
echo "Setting up init script..." echo "Setting up init script..."
logfile=/var/log/$app_id/$app_id_forked.log logfile=/var/log/$name/$app.log
sed -i "s@YUNOPORT@$port@g" ../conf/$app_id sed -i "s@YUNOPORT@$port@g" ../conf/$name
sed -i "s@YUNOLOG@$app_id_forked@g" ../conf/$app_id sed -i "s@YUNOLOG@$app@g" ../conf/$name
sed -i "s@YUNOPATH@$path@g" ../conf/$app_id sed -i "s@YUNOPATH@$path@g" ../conf/$name
sudo cp ../conf/$app_id /etc/init.d/$app_id_forked sudo cp ../conf/$name /etc/init.d/$app
sudo chmod +x /etc/init.d/$app_id_forked sudo chmod +x /etc/init.d/$app
sudo update-rc.d $app_id_forked defaults sudo update-rc.d $app defaults
if [ ! -d "/var/log/$app_id/" ]; then if [ ! -d "/var/log/$name/" ]; then
sudo mkdir /var/log/$app_id/ sudo mkdir /var/log/$name/
fi fi
sudo touch $logfile sudo touch $logfile
sudo chown $app_id_forked $logfile sudo chown $app $logfile
sudo service $app_id_forked stop sudo service $app stop
sudo service $app_id_forked start sudo service $app start
sudo yunohost service add $app_id_forked -l $logfile sudo yunohost service add $app -l $logfile
echo "Setting up logrotate configuration..." echo "Setting up logrotate configuration..."
sed -i "s@YNH_LOGFILE@$logfile@g" ../conf/logrotate sed -i "s@YNH_LOGFILE@$logfile@g" ../conf/logrotate
sudo cp ../conf/logrotate /etc/logrotate.d/$app_id_forked sudo cp ../conf/logrotate /etc/logrotate.d/$app
echo "Nginx configuration ..." 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*
sed -i "s@YUNOAPP@$app@g" ../conf/nginx.conf*
if [ "$path" = "" ]; if [ "$path" = "" ];
then then
sudo cp ../conf/nginx.conf-nosub /etc/nginx/conf.d/$domain.d/$app_id_forked.conf sudo cp ../conf/nginx.conf-nosub /etc/nginx/conf.d/$domain.d/$app.conf
else 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.conf
fi fi
echo "Reloading Nginx..." echo "Reloading Nginx..."