#!/bin/bash # Retrieve arguments domain=$1 path=$2 is_public=$3 # TODO : check if $path contains "ghost", refused by ghost # Check domain/path availability sudo yunohost app checkurl $domain$path -a ghostblog if [[ ! $? -eq 0 ]]; then exit 1 fi echo "Install dependencies" sudo apt-get install nodejs-legacy npm -y echo "Download sources..." version=0.4.1 echo "Downloading Ghost $version..." mkdir ../tmp sudo wget -O ../tmp/ghost-$version.zip "https://en.ghost.org/zip/ghost-$version.zip" unzip ../tmp/ghost-$version.zip -d ../tmp/ghost echo "Deploying source files..." final_path=/home/yunohost.app/ghostblog sudo mkdir -p $final_path sudo useradd -d $final_path ghostblog sudo cp -r ../tmp/ghost $final_path sudo chown -R ghostblog: $final_path echo "Install Ghost with NPM..." sudo su --shell /bin/bash --command "cd $final_path/ghost && npm install --production" ghostblog #echo "Install forever with NPM..." #sudo su --shell /bin/bash --command "cd $final_path && npm --prefix=$final_path install -g forever" ghostblog echo "Deploying configuration" sed -i "s@YNH_DOMAIN@$domain@g" ../conf/config.js sed -i "s@YNH_LOCATION@$path@g" ../conf/config.js sed -i "s@YNH_MAIL@@g" ../conf/config.js sudo cp ../conf/config.js $final_path/ghost echo "Nginx configuration..." sed -i "s@YNH_LOCATION@$path@g" ../conf/nginx.conf sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/ghostblog.conf echo "Init script..." sudo cp ../conf/init-script /etc/init.d/ynh-app-ghostblog sudo chmod +x /etc/init.d/ynh-app-ghostblog sudo update-rc.d ynh-app-ghostblog defaults sudo service ynh-app-ghostblog start echo "Reloading Nginx..." sudo service nginx reload sudo yunohost app ssowatconf # TODO : logs, is_public, auto set up admin section, mail in config.js, add to ynh service