seafile_ynh/scripts/install
Elie a65a1045f6 Install Seafile
Create DB
Add Nginx conf
2014-08-06 20:57:24 -04:00

55 lines
2.1 KiB
Text

# Retrieve arguments
domain=$1
path=$2
# Check domain/path availability
sudo yunohost app checkurl $domain$path -a seafile
if [[ ! $? -eq 0 ]]; then
exit 1
fi
# Check dependencies
sudo apt-get install -y python2.7 python-setuptools python-simplejson python-imaging python-mysqldb
# Generate random DES key & password
deskey=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d '[A-Za-z0-9]' | sed -n 's/\(.\{24\}\).*/\1/p')
db_pwd_ccnet=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d '[A-Za-z0-9]' | sed -n 's/\(.\{24\}\).*/\1/p')
db_pwd_seafile=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d '[A-Za-z0-9]' | sed -n 's/\(.\{24\}\).*/\1/p')
db_pwd_seahub=$(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 same database name and user
db_user_ccnet=seafile_ccnet
db_user_seafile=seafile_seafile
db_user_seahub=seafile_seahub
# Initialize databases and store mysql password for upgrade
sudo yunohost app initdb $seafile_ccnet -p $db_pwd -s $(readlink -e ../conf/SQL/ccnet_mysql.initial.sql)
sudo yunohost app setting seafile mysqlpwd_ccnet -v $db_pwd_ccnet
sudo yunohost app initdb $db_user_seafile -p $db_pwd -s $(readlink -e ../conf/SQL/seafile_mysql.initial.sql)
sudo yunohost app setting seafile mysqlpwd_seafile -v $db_pwd_seafile
sudo yunohost app initdb $seafile_seahub -p $db_pwd -s $(readlink -e ../conf/SQL/seahub_mysql.initial.sql)
sudo yunohost app setting seafile mysqlpwd_seahub -v $db_pwd_seahub
# Copy files to the right place
final_path=/var/www/seafile
sudo mkdir -p $final_path
sudo wget https://bitbucket.org/haiwen/seafile/downloads/seafile-server_3.0.4_i386.tar.gz
sudo tar xvzf seafile-server_*.tar.gz
sudo rm seafile-*.tar.gz
cd seafile-server-*
# Set permissions to roundcube directory
sudo chown -R www-data: $final_path
# Modify Nginx configuration file and copy it to Nginx conf directory
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/seafile.conf
# Reload Nginx and regenerate SSOwat conf
sudo service nginx reload
sudo yunohost app ssowatconf