#!/bin/bash #================================================= # GENERIC START #================================================= # Import common cmd source ./experimental_helper.sh source ./_common.sh # Source YunoHost helpers source /usr/share/yunohost/helpers # Stop script if errors ynh_abort_if_errors ynh_script_progression --message="Validating installation parameters..." # Retrieve arguments domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH server_name="$YNH_APP_ARG_SERVER_NAME" admin=$YNH_APP_ARG_ADMIN is_public=$YNH_APP_ARG_IS_PUBLIC seafile_data=/home/yunohost.app/seafile-data final_path=/opt/yunohost/$app seafile_user=$app admin_password=$YNH_APP_ARG_ADMIN_PASSWORD seafile_version=$(ynh_app_upstream_version) architecture=$(ynh_detect_arch) # Create special path with / at the end if [[ $path_url == '/' ]] then path_url2=$path_url else path_url2=$path_url"/" fi # Register (book) web path ynh_webpath_register --app $app --domain $domain --path_url $path_url # Check Final Path availability test ! -e "$final_path" || ynh_die --message "This path already contains a folder" if [ -e "$seafile_data" ]; then old_data_dir_path="$seafile_data$(date '+%Y%m%d.%H%M%S')" ynh_print_warn "A data directory already exist. Data was renamed to $old_data_dir_path" mv "$seafile_data" "$old_data_dir_path" fi # Find available ports ynh_script_progression --message="Finding available ports..." seahub_port=$(ynh_find_port --port 8000) fileserver_port=$(ynh_find_port --port 8082) webdav_port=$(ynh_find_port --port 8080) if [ $fileserver_port -eq $webdav_port ]; then webdav_port=$(ynh_find_port --port $((fileserver_port + 1))) fi # store config in yunohost ynh_script_progression --message="Storing installation settings..." ynh_app_setting_set --app $app --key server_name --value "$server_name" ynh_app_setting_set --app $app --key final_path --value $final_path ynh_app_setting_set --app $app --key seafile_user --value $seafile_user ynh_app_setting_set --app $app --key admin --value $admin ynh_app_setting_set --app $app --key seahub_port --value $seahub_port ynh_app_setting_set --app $app --key fileserver_port --value $fileserver_port ynh_app_setting_set --app $app --key webdav_port --value $webdav_port ynh_app_setting_set --app $app --key is_public --value $is_public #================================================= # STANDARD MODIFICATIONS #================================================= ynh_script_progression --message="Creating base directory..." mkdir -p $final_path mkdir -p $final_path/installed mkdir -p $final_path/logs mkdir -p $seafile_data ln -s $seafile_data $final_path/seafile-data # Create User ynh_script_progression --message="Configuring system user..." ynh_system_user_create --username $seafile_user --home_dir $final_path # Check dependencies ynh_script_progression --message="Installing dependencies..." --weight=7 install_dependance # Download new version from sources ynh_script_progression --message="Installing sources files..." --weight=7 install_source # init databases ynh_script_progression --message="Configuring MySQL database..." db_user=seafile ynh_mysql_setup_db --db_user $db_user --db_name ccnetdb ynh_mysql_setup_db --db_user $db_user --db_name seafiledb --db_pwd "$db_pwd" ynh_mysql_setup_db --db_user $db_user --db_name seahubdb --db_pwd "$db_pwd" ynh_script_progression --message="Configuring application..." --weight=3 # Run install script chmod +x expect_scripts/install.exp chmod +x $final_path/seafile-server-$seafile_version/setup-seafile-mysql.sh expect_scripts/install.exp "$final_path/seafile-server-$seafile_version" "$server_name" "$domain" "$seafile_data" "$fileserver_port" "$db_pwd" sleep 3 # Update seafile config ynh_replace_string --match_string http:// --replace_string https:// --target_file $final_path/conf/ccnet.conf ynh_replace_string --match_string :8000 --replace_string $path_url --target_file $final_path/conf/ccnet.conf echo 'FILE_SERVER_ROOT = "https://'$domain'/seafhttp"' | tee -a $final_path/conf/seahub_settings.py echo 'SITE_ROOT = "'$path_url2'"' | tee -a $final_path/conf/seahub_settings.py echo 'SERVE_STATIC = False' | tee -a $final_path/conf/seahub_settings.py echo 'MEDIA_URL = "'$path_url2'media/"' | tee -a $final_path/conf/seahub_settings.py echo 'COMPRESS_URL = MEDIA_URL' | tee -a $final_path/conf/seahub_settings.py echo "STATIC_URL = MEDIA_URL + 'assets/'" | tee -a $final_path/conf/seahub_settings.py echo "LOGIN_URL = '"$path_url2"accounts/login/'" | tee -a $final_path/conf/seahub_settings.py echo "ALLOWED_HOSTS = ['"$domain"']" | tee -a $final_path/conf/seahub_settings.py # Email configuration echo 'EMAIL_USE_TLS = False' | tee -a $final_path/conf/seahub_settings.py echo 'EMAIL_HOST = "localhost"' | tee -a $final_path/conf/seahub_settings.py echo 'EMAIL_HOST_USER = "seafile@'$domain'"' | tee -a $final_path/conf/seahub_settings.py echo 'EMAIL_PORT = "25"' | tee -a $final_path/conf/seahub_settings.py echo 'DEFAULT_FROM_EMAIL = "seafile@'$domain'"' | tee -a $final_path/conf/seahub_settings.py echo 'SERVER_EMAIL = "seafile@'$domain'"' | tee -a $final_path/conf/seahub_settings.py echo 'EMAIL_HOST_PASSWORD = ""' | tee -a $final_path/conf/seahub_settings.py echo "TIME_ZONE = \"$(cat /etc/timezone)\"" | tee -a $final_path/conf/seahub_settings.py # SSO authentication echo 'ENABLE_REMOTE_USER_AUTHENTICATION = True' | tee -a $final_path/conf/seahub_settings.py echo "REMOTE_USER_HEADER = 'HTTP_EMAIL'" | tee -a $final_path/conf/seahub_settings.py echo 'REMOTE_USER_CREATE_UNKNOWN_USER = False' | tee -a $final_path/conf/seahub_settings.py echo "REMOTE_USER_PROTECTED_PATH = ['$path_url', '$path_url/accounts/login']" | tee -a $final_path/conf/seahub_settings.py # LDAP configuration echo '[LDAP]' | tee -a $final_path/conf/ccnet.conf echo 'HOST = ldap://localhost:389' | tee -a $final_path/conf/ccnet.conf echo 'BASE = ou=users,dc=yunohost,dc=org' | tee -a $final_path/conf/ccnet.conf echo 'LOGIN_ATTR = mail' | tee -a $final_path/conf/ccnet.conf # Enable manually wiki echo 'ENABLE_WIKI = True' | tee -a $final_path/conf/seahub_settings.py # Enable memcached cat >> $final_path/conf/seahub_settings.py <