#!/bin/bash # Retrieve arguments domain=$(sudo yunohost app setting kiwiirc domain) path=$(sudo yunohost app setting kiwiirc path) is_public=$(sudo yunohost app setting kiwiirc is_public) sudo service ynh-kiwiirc stop sudo update-rc.d ynh-kiwiirc remove sudo yunohost service remove ynh-kiwiirc 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 rm -rf $final_path/* 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 !"