mirror of
https://github.com/YunoHost-Apps/seafile_ynh.git
synced 2024-09-03 20:26:01 +02:00
edbbbc57b3
not working commit
Former-commit-id: ad02ca97bb
134 lines
4.5 KiB
Text
134 lines
4.5 KiB
Text
# Retrieve arguments
|
|
domain=$1
|
|
path=$2
|
|
server_name=$3
|
|
admin=$4
|
|
admin_password=$5
|
|
is_public=$6
|
|
final_path=/var/www/seafile
|
|
seafile_data=/home/yunohost.app/seafile-data
|
|
seafile_version=4.0.6
|
|
|
|
# Retrieve admin email
|
|
admin_email=$(sudo yunohost user info $admin | grep mail: | sed "s/mail: //g")
|
|
|
|
port=''
|
|
findPort () {
|
|
|
|
port=$1
|
|
|
|
sudo yunohost app checkport $port
|
|
while [[ ! $? -eq 0 ]]
|
|
do
|
|
port=$(($port + 1))
|
|
sudo yunohost app checkport $port
|
|
done
|
|
|
|
return $port
|
|
}
|
|
|
|
# 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 -qq python2.7 python-setuptools python-simplejson python-imaging python-mysqldb python-flup expect
|
|
|
|
# Copy files to the right place
|
|
sudo mkdir -p $final_path
|
|
sudo mkdir -p $final_path/installed
|
|
sudo mkdir -p $final_path/logs
|
|
sudo mkdir -p $final_path/seafile-data
|
|
sudo mkdir -p $final_path/seafile-server-$seafile_version
|
|
sudo tar xzf ../sources/'seafile-server_'$seafile_version'_x86-64.tar'
|
|
sudo mv seafile-server-$seafile_version/* $final_path/seafile-server-$seafile_version
|
|
sudo mv ../sources/'seafile-server_'$seafile_version'_x86-64.tar' $final_path/installed
|
|
|
|
# Find available ports
|
|
findPort 10001
|
|
ccnet_port=$port
|
|
findPort 12001
|
|
seafile_port=$port
|
|
findPort 8000
|
|
seahub_port=$port
|
|
findPort 8082
|
|
fileserver_port=$port
|
|
|
|
# store config in yunohost
|
|
sudo yunohost app setting seafile ccnet_port -v $ccnet_port
|
|
sudo yunohost app setting seafile seafile_port -v $seafile_port
|
|
sudo yunohost app setting seafile seahub_port -v $seahub_port
|
|
sudo yunohost app setting seafile fileserver_port -v $fileserver_port
|
|
sudo yunohost app setting seafile is_public -v $is_public
|
|
|
|
# init databases
|
|
db_user=seafile
|
|
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')
|
|
sudo yunohost app initdb -d ccnetdb -p $db_pwd $db_user
|
|
sudo yunohost app initdb -d seafiledb -p $db_pwd $db_user
|
|
sudo yunohost app initdb -d seahubdb -p $db_pwd $db_user
|
|
|
|
# Run install script
|
|
sudo chmod +x ../conf/install.exp
|
|
sudo chmod +x $final_path/seafile-server-$seafile_version/setup-seafile-mysql.sh
|
|
sudo ../conf/install.exp $server_name $domain $ccnet_port $seafile_data $seafile_port $fileserver_port $db_pwd
|
|
|
|
# Update seafile config
|
|
sudo sed -i "s@http://@https://@g" $final_path/ccnet/ccnet.conf
|
|
sudo sed -i "s@:8000@$path@g" $final_path/ccnet/ccnet.conf
|
|
echo 'FILE_SERVER_ROOT = "https://'$domain'/seafhttp"' | sudo tee -a $final_path/seahub_settings.py
|
|
echo 'SITE_ROOT = "'$path'/"' | sudo tee -a $final_path/seahub_settings.py
|
|
echo 'SERVE_STATIC = False' | sudo tee -a $final_path/seahub_settings.py
|
|
echo 'MEDIA_URL = "'$path'/media/"' | sudo tee -a $final_path/seahub_settings.py
|
|
|
|
# LDAP configuration
|
|
echo '[LDAP]' | sudo tee -a $final_path/ccnet/ccnet.conf
|
|
echo 'HOST = ldap://localhost:389' | sudo tee -a $final_path/ccnet/ccnet.conf
|
|
echo 'BASE = ou=users,dc=yunohost,dc=org' | sudo tee -a $final_path/ccnet/ccnet.conf
|
|
echo 'LOGIN_ATTR = mail' | sudo tee -a $final_path/ccnet/ccnet.conf
|
|
|
|
# Add Seafile Server to startup
|
|
sudo cp ../conf/seafile-server /etc/init.d
|
|
sudo sed -i "s@SEAHUB_PORT@$seahub_port@g" /etc/init.d/seafile-server
|
|
sudo sed -i "s@SEAFILE_DIR@$final_path@g" /etc/init.d/seafile-server
|
|
sudo chmod +x /etc/init.d/seafile-server
|
|
sudo update-rc.d seafile-server defaults
|
|
|
|
# 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
|
|
sed -i "s@SEAHUB_PORT@$seahub_port@g" ../conf/nginx.conf
|
|
sed -i "s@SEAFILE_FILESERVER_PORT@$fileserver_port@g" ../conf/nginx.conf
|
|
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/seafile.conf
|
|
|
|
# Set permissions to seafile directory
|
|
sudo chown -R www-data:www-data $final_path
|
|
sudo chown -R www-data:www-data $seafile_data
|
|
|
|
# Open port
|
|
sudo yunohost firewall allow $ccnet_port
|
|
sudo yunohost firewall allow $seafile_port
|
|
|
|
sudo yunohost app setting seafile skipped_uris -v "/media"
|
|
|
|
if [ "$is_public" = "No" ];
|
|
then
|
|
sudo yunohost app setting seafile skipped_uris -d
|
|
sudo yunohost app ssowatconf
|
|
else
|
|
sudo yunohost app setting seafile skipped_uris -v "/"
|
|
fi
|
|
|
|
# Start seafile, seahub and populate admin account
|
|
sudo /var/www/seafile/seafile-server-4.0.6/seafile.sh start
|
|
sudo chmod +x ../conf/first_launch.exp
|
|
sudo ../conf/first_launch.exp $admin_email $admin_password
|
|
|
|
# register yunohost service
|
|
sudo yunohost service add seafile-server
|
|
|
|
# Reload Nginx and regenerate SSOwat conf
|
|
sudo service nginx reload
|
|
sudo yunohost app ssowatconf
|