mirror of
https://github.com/YunoHost-Apps/diaspora_ynh.git
synced 2024-09-03 18:26:13 +02:00
117 lines
3.4 KiB
Bash
117 lines
3.4 KiB
Bash
#!/bin/bash
|
|
|
|
# Retrieve arguments
|
|
domain=$1
|
|
path=$2
|
|
user=$3
|
|
is_public=$4
|
|
|
|
# Check user parameter
|
|
sudo yunohost user list --json | grep -q "\"username\": \"$user\""
|
|
if [[ ! $? -eq 0 ]]; then
|
|
echo "Wrong user"
|
|
exit 1
|
|
fi
|
|
sudo yunohost app setting diaspora admin_user -v $user
|
|
|
|
# Check domain/path availability
|
|
sudo yunohost app checkurl $domain$path -a diaspora
|
|
if [[ ! $? -eq 0 ]]; then
|
|
exit 1
|
|
fi
|
|
|
|
ori_path=$(pwd)
|
|
final_path=/var/www/diaspora
|
|
full_url=https://$domain$path
|
|
|
|
# configure sys apt-get
|
|
|
|
cat /etc/apt/sources.list | grep -q backports
|
|
[ $? != 0 ] && sudo su -c "echo 'deb http://http.debian.net/debian wheezy-backports main' >> /etc/apt/sources.list"
|
|
|
|
# get sys deps
|
|
sudo apt-get update
|
|
sudo apt-get install gawk libyaml-dev libsqlite3-dev sqlite3 autoconf libgdbm-dev libncurses5-dev automake bison libffi-dev\
|
|
build-essential libssl-dev libcurl4-openssl-dev libxml2-dev libxslt-dev imagemagick ghostscript git curl libmysqlclient-dev\
|
|
libmagickwand-dev nodejs-legacy npm -y
|
|
sudo apt-get install -t wheezy-backports redis-server -y
|
|
|
|
# get source code
|
|
git clone -b master git://github.com/diaspora/diaspora.git
|
|
sudo mv diaspora $final_path
|
|
|
|
# Generate random password
|
|
|
|
db_pwd=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d 'A-Za-z0-9' | sed -n 's/\(.\{24\}\).*/\1/p')
|
|
|
|
# Use 'diaspora' as database name and user
|
|
db_user=diaspora
|
|
|
|
# Initialize database and store mysql password for upgrade
|
|
sudo yunohost app initdb $db_user -p $db_pwd -d diaspora_production
|
|
sudo yunohost app setting diaspora mysqlpwd -v $db_pwd
|
|
|
|
# prepare and copy diaspora config file
|
|
sed -i "s@FULLURLTOCHANGE@$full_url@g" ../conf/diaspora.yml
|
|
sed -i "s@DBUSERTOCHANGE@$db_user@g" ../conf/database.yml
|
|
sed -i "s@DBPASSTOCHANGE@$db_user@g" ../conf/database.yml
|
|
sudo cp ../conf/diaspora.yml $final_path/config/
|
|
sudo cp ../conf/database.yml $final_path/config/
|
|
sudo chown -R diaspora:diaspora $final_path
|
|
|
|
# install startup script
|
|
sudo cp ../conf/diaspora_ynh /etc/init.d/diaspora_ynh
|
|
sudo chmod 754 /etc/init.d/diaspora_ynh
|
|
sudo update-rc.d diaspora_ynh defaults
|
|
|
|
# create and config user
|
|
sudo adduser --gecos "First Last,RoomNumber,WorkPhone,HomePhone" --quiet --disabled-login --home $final_path diaspora
|
|
sudo chown -R diaspora:diaspora $final_path
|
|
sudo su diaspora
|
|
cd ~
|
|
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"' >> ~/.bashrc
|
|
|
|
# Config RVM
|
|
curl -sSL https://rvm.io/mpapis.asc | gpg --import -
|
|
curl -L dspr.tk/1t | bash
|
|
. ~/.bashrc
|
|
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
|
|
rvm install 2.0
|
|
|
|
cd $final_path
|
|
|
|
# force get app deps (for debug)
|
|
gem install nokogiri -v '1.6.1'
|
|
gem install raindrops -v '0.13.0'
|
|
|
|
# construct diaspora app
|
|
RAILS_ENV=production bundle install --without test development
|
|
RAILS_ENV=production bundle exec rake db:create db:schema:load
|
|
RAILS_ENV=production bundle exec rake assets:precompile
|
|
|
|
exit
|
|
|
|
cd $ori_path
|
|
|
|
# start service
|
|
sudo service diaspora_ynh start
|
|
|
|
# config nginx
|
|
sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf
|
|
sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf
|
|
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/diaspora.conf
|
|
|
|
# Reload Nginx and regenerate SSOwat conf
|
|
|
|
sudo service nginx reload
|
|
sudo yunohost app setting diaspora skipped_uris -v "/"
|
|
sudo yunohost app ssowatconf
|
|
|
|
#protect URIs
|
|
|
|
if [ $is_public = "No" ];
|
|
then
|
|
sudo yunohost app setting diaspora protected_uris -v "/"
|
|
sudo yunohost app ssowatconf
|
|
fi
|
|
|