1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/kiwiirc_ynh.git synced 2024-09-03 19:35:59 +02:00
kiwiirc_ynh/scripts/install
2014-09-19 19:01:04 +02:00

77 lines
2.4 KiB
Bash

#!/bin/bash
# Retrieve arguments
domain=$1
path=$2
is_public=$3
# Check domain/path availability
sudo yunohost app checkurl $domain$path -a kiwiirc
if [[ ! $? -eq 0 ]]; then
exit 1
fi
echo "Install dependencies..."
sudo apt-get update
sudo apt-get install nodejs-legacy npm -y
version=de1607bf1e9ba4429a10f895a6ec45c54daa3161
echo "Downloading KiwiIRC $version..."
mkdir ../tmp
sudo wget -O ../tmp/kiwiirc-$version.tar.gz "https://github.com/prawnsalad/KiwiIRC/archive/$version.tar.gz"
echo "Deploying source files..."
cd ../tmp && tar xvzf ../tmp/kiwiirc-$version.tar.gz && cd ../scripts
final_path=/var/www/kiwiirc
sudo mkdir -p $final_path
sudo useradd -d $final_path kiwiirc
sudo cp -r ../tmp/KiwiIRC-$version/* $final_path
#sudo cp ../conf/npm-shrinkwrap.json $final_path
sudo chown -R kiwiirc: $final_path
echo "Installing KiwiIRC with NPM..."
sudo su --shell /bin/bash --command "cd $final_path && npm install --production --registry http://registry.npmjs.org" kiwiirc
echo "Cleaning up install tree..."
sudo rm -rf $final_path/.npm
echo "Deploying configuration..."
sed -i "s@YNH_BASE_PATH@${path}@g" ../conf/config.js
sudo cp ../conf/config.js $final_path/config.js
sudo chown kiwiirc: $final_path/config.js
sudo chmod 644 $final_path/config.js
echo "Post install step... building client side"
sudo su --shell /bin/bash --command "cd $final_path && node $final_path/server/server.js build" kiwiirc
echo "Setting up init script..."
logfile=/var/log/ynh-kiwiirc.log
sudo touch $logfile
sudo chown kiwiirc: $logfile
sed -i "s@YNH_FINALPATH@$final_path@g" ../conf/init-script
sed -i "s@YNH_LOGFILE@$logfile@g" ../conf/init-script
sudo cp ../conf/init-script /etc/init.d/ynh-kiwiirc
sudo chmod +x /etc/init.d/ynh-kiwiirc
sudo update-rc.d ynh-kiwiirc defaults
sudo service ynh-kiwiirc start
sudo yunohost service add ynh-kiwiirc -l $logfile
echo "Setting up logrotate configuration..."
sed -i "s@YNH_LOGFILE@$logfile@g" ../conf/logrotate
sudo cp ../conf/logrotate /etc/logrotate.d/ynh-kiwiirc
echo "Nginx configuration..."
sed -i "s@YNH_LOCATION@$path@g" ../conf/nginx.conf
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/kiwiirc.conf
if [ $is_public = "Yes" ]; then
sudo yunohost app setting kiwiirc skipped_uris -v "/"
fi
sudo yunohost app setting kiwiirc is_public -v $is_public
echo "Reloading Nginx (sso enabled)..."
sudo service nginx reload
sudo yunohost app ssowatconf
echo "Success !"