mirror of
https://github.com/YunoHost-Apps/onlyoffice_ynh.git
synced 2024-09-03 19:56:11 +02:00
Merge pull request #16 from yalh76/example_ynh
Onlyoffice level 7 (apply last example_ynh rules)
This commit is contained in:
commit
c003d69da7
11 changed files with 521 additions and 353 deletions
|
@ -1,7 +1,7 @@
|
|||
# OnlyOffice for YunoHost
|
||||
|
||||
[](https://dash.yunohost.org/appci/app/onlyoffice)
|
||||
[](https://install-app.yunohost.org/?app=onlyoffice)
|
||||
[](https://install-app.yunohost.org/?app=onlyoffice)
|
||||
|
||||
> *This package allow you to install OnlyOffice quickly and simply on a YunoHost server.
|
||||
If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.*
|
||||
|
@ -15,9 +15,9 @@ OnlyOffice Document Server
|
|||
|
||||
#### Supported architectures
|
||||
|
||||
* x86-64b - [](https://ci-apps.yunohost.org/ci/apps/onlyoffice/)
|
||||
* ARMv8-A - [](https://ci-apps-arm.yunohost.org/ci/apps/onlyoffice/)
|
||||
* Jessie x86-64b - [](https://ci-stretch.nohost.me/ci/apps/onlyoffice/)
|
||||
* x86-64b - [](https://ci-apps.yunohost.org/ci/apps/onlyoffice/)
|
||||
* ARMv8-A - [](https://ci-apps-arm.yunohost.org/ci/apps/onlyoffice/)
|
||||
* Jessie x86-64b - [](https://ci-stretch.nohost.me/ci/apps/onlyoffice/)
|
||||
|
||||
## Links
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
setup_private=1
|
||||
setup_public=1
|
||||
upgrade=1
|
||||
upgrade=1 from_commit=c7d09d7f15a01e85e0354561d737523e1cb18749
|
||||
backup_restore=1
|
||||
multi_instance=0
|
||||
incorrect_path=1
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
"email": "liberodark@gmail.com"
|
||||
},
|
||||
"requirements": {
|
||||
"yunohost": ">= 3.4"
|
||||
"yunohost": ">= 3.5"
|
||||
},
|
||||
"multi_instance": false,
|
||||
"services": [
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# COMMON VARIABLES
|
||||
#=================================================
|
||||
|
||||
# dependencies used by the app
|
||||
pkg_dependencies="postgresql libstdc++6 redis-server rabbitmq-server libcurl4-nss-dev"
|
||||
|
||||
#=================================================
|
||||
# PERSONAL HELPERS
|
||||
#=================================================
|
||||
source="https://github.com/ONLYOFFICE/DocumentServer/releases/download/ONLYOFFICE-DocumentServer-5.2.8/onlyoffice-documentserver_amd64.deb"
|
||||
version="5.2.8"
|
||||
|
||||
#=================================================
|
||||
# EXPERIMENTAL HELPERS
|
||||
|
|
|
@ -14,56 +14,45 @@ source /usr/share/yunohost/helpers
|
|||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
ynh_clean_setup () {
|
||||
### Remove this function if there's nothing to clean before calling the remove script.
|
||||
true
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info "Loading installation settings..."
|
||||
ynh_print_info --message="Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
db_name=$(ynh_app_setting_get $app db_name)
|
||||
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
|
||||
#=================================================
|
||||
# STANDARD BACKUP STEPS
|
||||
#=================================================
|
||||
# BACKUP THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_print_info "Backing up the main app directory..."
|
||||
|
||||
ynh_backup "$final_path"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info "Backing up nginx web server configuration..."
|
||||
ynh_print_info --message="Backing up nginx web server configuration..."
|
||||
|
||||
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
ynh_print_info "Backing up the PostgreSQL database..."
|
||||
ynh_print_info --message="Backing up the PostgreSQL database..."
|
||||
|
||||
ynh_psql_dump_db "$db_name" > db.sql
|
||||
ynh_psql_dump_db --database="$db_name" > db.sql
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC BACKUP
|
||||
#=================================================
|
||||
ynh_print_info "Backing up the configuration..."
|
||||
ynh_print_info --message="Backing up the configuration..."
|
||||
|
||||
ynh_backup "/etc/onlyoffice"
|
||||
ynh_backup --src_path="/etc/onlyoffice"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
||||
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
||||
|
|
|
@ -24,25 +24,15 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info "Loading installation settings..."
|
||||
ynh_print_info --message="Loading installation settings..."
|
||||
|
||||
# Needed for helper "ynh_add_nginx_config"
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
port=$(ynh_app_setting_get $app port)
|
||||
nextclouddomain=$(ynh_app_setting_get $app nextclouddomain)
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
nextclouddomain=$(ynh_app_setting_get --app=$app --key=nextclouddomain)
|
||||
|
||||
# Add settings here as needed by your application
|
||||
#db_name=$(ynh_app_setting_get "$app" db_name)
|
||||
#db_pwd=$(ynh_app_setting_get $app db_pwd)
|
||||
|
||||
#=================================================
|
||||
# CHECK THE SYNTAX OF THE PATHS
|
||||
#=================================================
|
||||
|
||||
test -n "$old_path" || old_path="/"
|
||||
test -n "$new_path" || new_path="/"
|
||||
new_path=$(ynh_normalize_url_path $new_path)
|
||||
old_path=$(ynh_normalize_url_path $old_path)
|
||||
#db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
#db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
|
||||
|
||||
#=================================================
|
||||
# CHECK WHICH PARTS SHOULD BE CHANGED
|
||||
|
@ -65,7 +55,7 @@ fi
|
|||
#=================================================
|
||||
# MODIFY URL IN NGINX CONF
|
||||
#=================================================
|
||||
ynh_print_info "Updating nginx web server configuration..."
|
||||
ynh_print_info --message="Updating nginx web server configuration..."
|
||||
|
||||
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
||||
|
||||
|
@ -73,16 +63,15 @@ nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
|||
if [ $change_path -eq 1 ]
|
||||
then
|
||||
# Make a backup of the original nginx config file if modified
|
||||
ynh_backup_if_checksum_is_different "$nginx_conf_path"
|
||||
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
|
||||
# Set global variables for nginx helper
|
||||
domain="$old_domain"
|
||||
path_url="$new_path"
|
||||
|
||||
### `ynh_add_nginx_config` will use the file conf/nginx.conf
|
||||
if [ $new_path = "/" ]; then
|
||||
ynh_replace_string "__SUB_PATH__" "" "../conf/nginx.conf"
|
||||
ynh_replace_string --match_string="__SUB_PATH__" --replace_string="" --target_file="../conf/nginx.conf"
|
||||
else
|
||||
ynh_replace_string "__SUB_PATH__" "$new_path" "../conf/nginx.conf"
|
||||
ynh_replace_string --match_string="__SUB_PATH__" --replace_string="$new_path" --target_file="../conf/nginx.conf"
|
||||
fi
|
||||
|
||||
# Create a dedicated nginx config
|
||||
|
@ -93,31 +82,25 @@ fi
|
|||
if [ $change_domain -eq 1 ]
|
||||
then
|
||||
# Delete file checksum for the old conf file location
|
||||
ynh_delete_file_checksum "$nginx_conf_path"
|
||||
ynh_delete_file_checksum --file="$nginx_conf_path"
|
||||
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
||||
# Store file checksum for the new config file location
|
||||
ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||
ynh_replace_string "X-Frame-Options : ALLOW-FROM https://$nextclouddomain" "X-Frame-Options : SAMEORIGIN" "/etc/nginx/conf.d/$old_domain.conf"
|
||||
ynh_replace_string "X-Frame-Options : SAMEORIGIN" "X-Frame-Options : ALLOW-FROM https://$nextclouddomain" "/etc/nginx/conf.d/$new_domain.conf"
|
||||
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||
ynh_replace_string --match_string="X-Frame-Options : ALLOW-FROM https://$nextclouddomain" --replace_string="X-Frame-Options : SAMEORIGIN" --target_file="/etc/nginx/conf.d/$old_domain.conf"
|
||||
ynh_replace_string --match_string="X-Frame-Options : SAMEORIGIN" --replace_string="X-Frame-Options : ALLOW-FROM https://$nextclouddomain" --target_file="/etc/nginx/conf.d/$new_domain.conf"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC MODIFICATIONS
|
||||
#=================================================
|
||||
# ...
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALISATION
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_print_info "Reloading nginx web server..."
|
||||
ynh_print_info --message="Reloading nginx web server..."
|
||||
|
||||
systemctl reload nginx
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Change of URL completed for $app"
|
||||
ynh_print_info --message="Change of URL completed for $app"
|
||||
|
|
182
scripts/install
182
scripts/install
|
@ -7,16 +7,13 @@
|
|||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source ynh_add_extra_apt_repos__3
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
ynh_clean_setup () {
|
||||
### Remove this function if there's nothing to clean before calling the remove script.
|
||||
true
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
|
@ -29,233 +26,162 @@ path_url=$YNH_APP_ARG_PATH
|
|||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||
nextclouddomain=$YNH_APP_ARG_NEXTCLOUDDOMAIN
|
||||
|
||||
### If it's a multi-instance app, meaning it can be installed several times independently
|
||||
### The id of the app as stated in the manifest is available as $YNH_APP_ID
|
||||
### The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...)
|
||||
### The app instance name is available as $YNH_APP_INSTANCE_NAME
|
||||
### - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample
|
||||
### - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2
|
||||
### - ynhexample__{N} for the subsequent installations, with N=3,4, ...
|
||||
### The app instance name is probably what interests you most, since this is
|
||||
### guaranteed to be unique. This is a good unique identifier to define installation path,
|
||||
### db names, ...
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||
#=================================================
|
||||
ynh_print_info "Validating installation parameters..."
|
||||
|
||||
### If the app uses nginx as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app".
|
||||
### If the app provides an internal web server (or uses another application server such as uwsgi), the final path should be "/opt/yunohost/$app"
|
||||
final_path=/var/www/$app
|
||||
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
||||
|
||||
# Normalize the url path syntax
|
||||
path_url=$(ynh_normalize_url_path $path_url)
|
||||
ynh_print_info --message="Validating installation parameters..."
|
||||
|
||||
# Register (book) web path
|
||||
ynh_webpath_register $app $domain $path_url
|
||||
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
||||
|
||||
#=================================================
|
||||
# STORE SETTINGS FROM MANIFEST
|
||||
#=================================================
|
||||
ynh_print_info "Storing installation settings..."
|
||||
ynh_print_info --message="Storing installation settings..."
|
||||
|
||||
ynh_app_setting_set $app domain $domain
|
||||
ynh_app_setting_set $app path $path_url
|
||||
ynh_app_setting_set $app is_public $is_public
|
||||
ynh_app_setting_set $app nextclouddomain $nextclouddomain
|
||||
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
||||
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
||||
ynh_app_setting_set --app=$app --key=is_public --value=$is_public
|
||||
ynh_app_setting_set --app=$app --key=nextclouddomain --value=$nextclouddomain
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
# FIND AND OPEN A PORT
|
||||
#=================================================
|
||||
ynh_print_info "Configuring firewall..."
|
||||
|
||||
### Use these lines if you have to open a port for the application
|
||||
### `ynh_find_port` will find the first available port starting from the given port.
|
||||
### If you're not using these lines:
|
||||
### - Remove the section "CLOSE A PORT" in the remove script
|
||||
ynh_print_info --message="Configuring firewall..."
|
||||
|
||||
# Find a free port
|
||||
port=$(ynh_find_port 8095)
|
||||
# Open this port
|
||||
#ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port
|
||||
ynh_app_setting_set $app port $port
|
||||
port=$(ynh_find_port --port=8095)
|
||||
ynh_app_setting_set --app=$app --key=port --value=$port
|
||||
|
||||
#=================================================
|
||||
# ADD NODEJS REPOSITORY
|
||||
#=================================================
|
||||
ynh_print_info "Add nodejs repository..."
|
||||
ynh_print_info --message="Add nodejs repository..."
|
||||
|
||||
curl -sL https://deb.nodesource.com/setup_8.x | sudo bash -
|
||||
ynh_install_extra_repo --repo="deb https://deb.nodesource.com/node_8.x stretch main" --key="https://deb.nodesource.com/gpgkey/nodesource.gpg.key"
|
||||
|
||||
#=================================================
|
||||
# ADD ONLYOFFICE REPOSITORY
|
||||
#=================================================
|
||||
ynh_print_info "Add OnlyOffice repository..."
|
||||
ynh_print_info --message="Add OnlyOffice repository..."
|
||||
|
||||
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CB2DE8E5
|
||||
echo "deb http://download.onlyoffice.com/repo/debian squeeze main" | sudo tee /etc/apt/sources.list.d/onlyoffice.list
|
||||
ynh_install_extra_repo --repo="deb http://download.onlyoffice.com/repo/debian squeeze main" --append
|
||||
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_print_info "Installing dependencies..."
|
||||
ynh_print_info --message="Installing dependencies..."
|
||||
|
||||
### `ynh_install_app_dependencies` allows you to add any "apt" dependencies to the package.
|
||||
### Those deb packages will be installed as dependencies of this package.
|
||||
### If you're not using this helper:
|
||||
### - Remove the section "REMOVE DEPENDENCIES" in the remove script
|
||||
### - As well as the section "REINSTALL DEPENDENCIES" in the restore script
|
||||
### - And the section "UPGRADE DEPENDENCIES" in the upgrade script
|
||||
|
||||
ynh_install_app_dependencies postgresql libstdc++6 redis-server rabbitmq-server
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
# CREATE A POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
ynh_print_info "Creating a PostgreSQL database..."
|
||||
ynh_print_info --message="Creating a PostgreSQL database..."
|
||||
|
||||
### Use these lines if you need a database for the application.
|
||||
### `ynh_mysql_setup_db` will create a database, an associated user and a ramdom password.
|
||||
### The password will be stored as 'mysqlpwd' into the app settings,
|
||||
### and will be available as $db_pwd
|
||||
### If you're not using these lines:
|
||||
### - Remove the section "BACKUP THE POSTGRESQL DATABASE" in the backup script
|
||||
### - Remove also the section "REMOVE THE POSTGRESQL DATABASE" in the remove script
|
||||
### - As well as the section "RESTORE THE POSTGRESQL DATABASE" in the restore script
|
||||
|
||||
db_name=$(ynh_sanitize_dbid $app)
|
||||
db_pwd="onlyoffice"
|
||||
ynh_app_setting_set $app db_name $db_name
|
||||
ynh_app_setting_set $app db_pwd $db_pwd
|
||||
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
||||
db_user=$db_name
|
||||
db_pwd=$(ynh_string_random --length=32)
|
||||
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||
ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd
|
||||
ynh_psql_test_if_first_run
|
||||
ynh_psql_create_db $db_name $db_name $db_pwd
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_print_info "Setting up source files..."
|
||||
|
||||
### `ynh_setup_source` is used to install an app from a zip or tar.gz file,
|
||||
### downloaded from an upstream source, like a git repository.
|
||||
### `ynh_setup_source` use the file conf/app.src
|
||||
|
||||
ynh_app_setting_set $app final_path $final_path
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
#ynh_setup_source "$final_path"
|
||||
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info "Configuring nginx web server..."
|
||||
ynh_print_info --message="Configuring nginx web server..."
|
||||
|
||||
### `ynh_add_nginx_config` will use the file conf/nginx.conf
|
||||
if [ $path_url = "/" ]; then
|
||||
ynh_replace_string "__SUB_PATH__" "" "../conf/nginx.conf"
|
||||
ynh_replace_string --match_string="__SUB_PATH__" --replace_string="" --target_file="../conf/nginx.conf"
|
||||
else
|
||||
ynh_replace_string "__SUB_PATH__" "$path_url" "../conf/nginx.conf"
|
||||
ynh_replace_string --match_string="__SUB_PATH__" --replace_string="$path_url" --target_file="../conf/nginx.conf"
|
||||
fi
|
||||
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config "nextclouddomain"
|
||||
|
||||
# Fix main domain X-Frame-Options
|
||||
ynh_replace_string "X-Frame-Options : SAMEORIGIN" "X-Frame-Options : ALLOW-FROM https://$nextclouddomain" "/etc/nginx/conf.d/$domain.conf"
|
||||
ynh_replace_string --match_string="X-Frame-Options : SAMEORIGIN" --replace_string="X-Frame-Options : ALLOW-FROM https://$nextclouddomain" --target_file="/etc/nginx/conf.d/$domain.conf"
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_print_info "Configuring system user..."
|
||||
ynh_print_info --message="Configuring system user..."
|
||||
|
||||
# Create a system user
|
||||
ynh_system_user_create $app $final_path
|
||||
ynh_system_user_create --username=$app
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC SETUP
|
||||
#=================================================
|
||||
# DEFINE PORT
|
||||
# CONFIGURE ONLYOFFICE
|
||||
#=================================================
|
||||
ynh_print_info "Define OnlyOffice server port..."
|
||||
ynh_print_info --message="Configuring Onlyoffice..."
|
||||
|
||||
echo onlyoffice-documentserver onlyoffice/ds-port select ${port} | sudo debconf-set-selections
|
||||
echo onlyoffice-documentserver onlyoffice/ds-port select $port | sudo debconf-set-selections
|
||||
echo onlyoffice-documentserver onlyoffice/db-host string 127.0.0.1 | sudo debconf-set-selections
|
||||
echo onlyoffice-documentserver onlyoffice/db-user string $db_user | sudo debconf-set-selections
|
||||
echo onlyoffice-documentserver onlyoffice/db-pwd password $db_pwd | debconf-set-selections
|
||||
echo onlyoffice-documentserver onlyoffice/db-name string $db_name | sudo debconf-set-selections
|
||||
|
||||
#=================================================
|
||||
# INSTALL ONLYOFFICE
|
||||
#=================================================
|
||||
ynh_print_info "Install OnlyOffice..."
|
||||
ynh_print_info --message="Install OnlyOffice..."
|
||||
|
||||
wget $source
|
||||
ynh_package_install ./onlyoffice-documentserver_amd64.deb
|
||||
ynh_add_app_dependencies --package="onlyoffice-documentserver"
|
||||
|
||||
#=================================================
|
||||
# MODIFY A CONFIG FILE
|
||||
#=================================================
|
||||
|
||||
### `ynh_replace_string` is used to replace a string in a file.
|
||||
### (It's compatible with sed regular expressions syntax)
|
||||
|
||||
#ynh_replace_string "match_string" "replace_string" "$final_path/CONFIG_FILE"
|
||||
ynh_replace_string --match_string="\"rejectUnauthorized\": true" --replace_string="\"rejectUnauthorized\": false" --target_file="/etc/onlyoffice/documentserver/default.json"
|
||||
|
||||
#=================================================
|
||||
# STORE THE CONFIG FILE CHECKSUM
|
||||
#=================================================
|
||||
|
||||
### `ynh_store_file_checksum` is used to store the checksum of a file.
|
||||
### That way, during the upgrade script, by using `ynh_backup_if_checksum_is_different`,
|
||||
### you can make a backup of this file before modifying it again if the admin had modified it.
|
||||
|
||||
# Calculate and store the config file checksum into the app settings
|
||||
#ynh_store_file_checksum "/etc/onlyoffice/documentserver/nginx/onlyoffice-documentserver.conf"
|
||||
ynh_store_file_checksum --file="/etc/onlyoffice/documentserver/default.json"
|
||||
|
||||
#=================================================
|
||||
# RELOAD ONLYOFFICE
|
||||
#=================================================
|
||||
ynh_print_info --message="Reloading OnlyOffice..."
|
||||
|
||||
supervisorctl restart all
|
||||
|
||||
sleep 30
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# SECURE FILES AND DIRECTORIES
|
||||
#=================================================
|
||||
|
||||
### For security reason, any app should set the permissions to root: before anything else.
|
||||
### Then, if write authorization is needed, any access should be given only to directories
|
||||
### that really need such authorization.
|
||||
|
||||
# Set permissions to app files
|
||||
#chown -R $app: $final_path
|
||||
|
||||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
ynh_print_info "Configuring SSOwat..."
|
||||
ynh_print_info --message="Configuring SSOwat..."
|
||||
|
||||
# Make app public if necessary
|
||||
if [ $is_public -eq 1 ]
|
||||
then
|
||||
# unprotected_uris allows SSO credentials to be passed anyway.
|
||||
ynh_app_setting_set $app unprotected_uris "/"
|
||||
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_print_info "Reloading nginx web server..."
|
||||
ynh_print_info --message="Reloading nginx web server..."
|
||||
|
||||
systemctl reload nginx
|
||||
|
||||
#=================================================
|
||||
# RELOAD ONLYOFFICE
|
||||
#=================================================
|
||||
ynh_print_info "Reloading OnlyOffice..."
|
||||
|
||||
supervisorctl stop all
|
||||
supervisorctl start all
|
||||
|
||||
sleep 30
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Installation of $app completed"
|
||||
ynh_print_info --message="Installation of $app completed"
|
||||
|
|
|
@ -7,111 +7,92 @@
|
|||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source ynh_add_extra_apt_repos__3
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info "Loading installation settings..."
|
||||
ynh_print_info --message="Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
port=$(ynh_app_setting_get $app port)
|
||||
db_name=$(ynh_app_setting_get $app db_name)
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
db_user=$db_name
|
||||
|
||||
#=================================================
|
||||
# STANDARD REMOVE
|
||||
#=================================================
|
||||
# STOP ONLYOFFICE
|
||||
#=================================================
|
||||
ynh_print_info "Stopping OnlyOffice"
|
||||
ynh_print_info --message="Stopping OnlyOffice..."
|
||||
|
||||
supervisorctl stop all
|
||||
|
||||
#=================================================
|
||||
# REMOVE ONLYOFFICE
|
||||
#=================================================
|
||||
ynh_print_info "Removing OnlyOffice"
|
||||
ynh_print_info --message="Removing OnlyOffice..."
|
||||
|
||||
ynh_secure_remove /var/lib/dpkg/info/onlyoffice-documentserver.prerm
|
||||
ynh_secure_remove --file=/var/lib/dpkg/info/onlyoffice-documentserver.prerm
|
||||
ynh_package_autopurge onlyoffice-documentserver
|
||||
|
||||
#=================================================
|
||||
# REMOVE THE POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
ynh_print_info "Removing the PostgreSQL database"
|
||||
ynh_print_info --message="Removing the PostgreSQL database..."
|
||||
|
||||
# Remove a database if it exists, along with the associated user
|
||||
ynh_psql_remove_db $db_name $db_name
|
||||
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
|
||||
|
||||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_print_info "Removing dependencies"
|
||||
ynh_print_info --message="Removing dependencies..."
|
||||
|
||||
# Remove metapackage and its dependencies
|
||||
ynh_remove_app_dependencies
|
||||
ynh_remove_extra_repo
|
||||
|
||||
#=================================================
|
||||
# REMOVE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_print_info "Removing app main directory"
|
||||
|
||||
# Remove the app directory securely
|
||||
ynh_secure_remove "$final_path"
|
||||
apt-key del "E09C A29F 6E17 8040 EF22 B409 8320 CA65 CB2D E8E5"
|
||||
|
||||
#=================================================
|
||||
# REMOVE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info "Removing nginx web server configuration"
|
||||
ynh_print_info --message="Removing nginx web server configuration..."
|
||||
|
||||
# Remove the dedicated nginx config
|
||||
ynh_remove_nginx_config
|
||||
|
||||
#=================================================
|
||||
# CLOSE A PORT
|
||||
#=================================================
|
||||
|
||||
if yunohost firewall list | grep -q "\- $port$"
|
||||
then
|
||||
ynh_print_info "Closing port $port"
|
||||
ynh_exec_warn_less yunohost firewall disallow TCP $port
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC REMOVE
|
||||
#=================================================
|
||||
# REMOVE THE CRON FILE
|
||||
# REMOVE FILE
|
||||
#=================================================
|
||||
|
||||
# Remove a cron file
|
||||
#ynh_secure_remove "/etc/cron.d/$app"
|
||||
|
||||
# Remove a directory securely
|
||||
ynh_secure_remove "/etc/apt/sources.list.d/onlyoffice.list"
|
||||
ynh_secure_remove "/etc/apt/sources.list.d/nodesource.list"
|
||||
ynh_secure_remove "/etc/onlyoffice"
|
||||
ynh_secure_remove "/var/lib/onlyoffice"
|
||||
ynh_secure_remove "/var/cache/nginx/onlyoffice"
|
||||
ynh_secure_remove --file="/etc/onlyoffice"
|
||||
ynh_secure_remove --file="/var/lib/onlyoffice"
|
||||
ynh_secure_remove --file="/var/cache/nginx/onlyoffice"
|
||||
|
||||
# Remove the log files
|
||||
ynh_secure_remove "/var/log/$app/"
|
||||
ynh_secure_remove --file="/var/log/$app/"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# REMOVE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_print_info "Removing the dedicated system user"
|
||||
ynh_print_info --message="Removing the dedicated system user..."
|
||||
|
||||
# Delete a system user
|
||||
gpasswd -d www-data onlyoffice
|
||||
ynh_system_user_delete $app
|
||||
ynh_system_user_delete --username=$app
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Removal of $app completed"
|
||||
ynh_print_info --message="Removal of $app completed"
|
||||
|
|
110
scripts/restore
110
scripts/restore
|
@ -7,43 +7,39 @@
|
|||
#=================================================
|
||||
|
||||
source ../settings/scripts/_common.sh
|
||||
source ../settings/scripts/ynh_add_extra_apt_repos__3
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
#=================================================
|
||||
|
||||
ynh_clean_setup () {
|
||||
#### Remove this function if there's nothing to clean before calling the remove script.
|
||||
true
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info "Loading settings..."
|
||||
ynh_print_info --message="Loading settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
path_url=$(ynh_app_setting_get $app path)
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
db_name=$(ynh_app_setting_get $app db_name)
|
||||
db_pwd=$(ynh_app_setting_get $app db_pwd)
|
||||
port=$(ynh_app_setting_get $app port)
|
||||
nextclouddomain=$(ynh_app_setting_get $app nextclouddomain)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
db_user=$db_name
|
||||
db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
nextclouddomain=$(ynh_app_setting_get --app=$app --key=nextclouddomain)
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE RESTORED
|
||||
#=================================================
|
||||
ynh_print_info "Validating restoration parameters..."
|
||||
ynh_print_info --message="Validating restoration parameters..."
|
||||
|
||||
ynh_webpath_available $domain $path_url \
|
||||
|| ynh_die "Path not available: ${domain}${path_url}"
|
||||
test ! -d $final_path \
|
||||
|| ynh_die "There is already a directory: $final_path "
|
||||
ynh_webpath_available --domain=$domain --path_url=$path_url \
|
||||
|| ynh_die --message="Path not available: ${domain}${path_url}"
|
||||
|
||||
#=================================================
|
||||
# STANDARD RESTORATION STEPS
|
||||
|
@ -51,105 +47,93 @@ test ! -d $final_path \
|
|||
# RESTORE THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
# Fix main domain X-Frame-Options
|
||||
ynh_replace_string "X-Frame-Options : SAMEORIGIN" "X-Frame-Options : ALLOW-FROM https://$nextclouddomain" "/etc/nginx/conf.d/$domain.conf"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_print_info "Restoring the app main directory..."
|
||||
|
||||
ynh_restore_file "$final_path"
|
||||
ynh_replace_string --match_string="X-Frame-Options : SAMEORIGIN" --replace_string="X-Frame-Options : ALLOW-FROM https://$nextclouddomain" --target_file="/etc/nginx/conf.d/$domain.conf"
|
||||
|
||||
#=================================================
|
||||
# RECREATE THE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_print_info "Recreating the dedicated system user..."
|
||||
ynh_print_info --message="Recreating the dedicated system user..."
|
||||
|
||||
# Create the dedicated user (if not existing)
|
||||
ynh_system_user_create $app $final_path
|
||||
|
||||
#=================================================
|
||||
# RESTORE USER RIGHTS
|
||||
#=================================================
|
||||
|
||||
# Restore permissions on app files
|
||||
chown -R $app: $final_path
|
||||
ynh_system_user_create --username=$app
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC RESTORATION
|
||||
#=================================================
|
||||
# RESTORE THE CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info "Restoring the configuration..."
|
||||
|
||||
ynh_restore_file "/etc/onlyoffice"
|
||||
|
||||
#=================================================
|
||||
# ADD NODEJS REPOSITORY
|
||||
#=================================================
|
||||
ynh_print_info "Add nodejs repository..."
|
||||
ynh_print_info --message="Add nodejs repository..."
|
||||
|
||||
curl -sL https://deb.nodesource.com/setup_8.x | sudo bash -
|
||||
ynh_install_extra_repo --repo="deb https://deb.nodesource.com/node_8.x stretch main" --key="https://deb.nodesource.com/gpgkey/nodesource.gpg.key"
|
||||
|
||||
#=================================================
|
||||
# ADD ONLYOFFICE REPOSITORY
|
||||
#=================================================
|
||||
ynh_print_info "Add OnlyOffice repository..."
|
||||
ynh_print_info --message="Add OnlyOffice repository..."
|
||||
|
||||
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CB2DE8E5
|
||||
echo "deb http://download.onlyoffice.com/repo/debian squeeze main" | sudo tee /etc/apt/sources.list.d/onlyoffice.list
|
||||
ynh_install_extra_repo --repo="deb http://download.onlyoffice.com/repo/debian squeeze main" --append
|
||||
|
||||
#=================================================
|
||||
# REINSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_print_info "Reinstalling dependencies..."
|
||||
ynh_print_info --message="Reinstalling dependencies..."
|
||||
|
||||
# Define and install dependencies
|
||||
ynh_install_app_dependencies postgresql libstdc++6 redis-server rabbitmq-server
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
ynh_print_info "Restoring the PostgreSQL database..."
|
||||
ynh_print_info --message="Restoring the PostgreSQL database..."
|
||||
|
||||
ynh_psql_test_if_first_run
|
||||
ynh_psql_create_db $db_name $db_name $db_pwd
|
||||
ynh_psql_execute_file_as_root ./db.sql "$db_name"
|
||||
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
|
||||
ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name
|
||||
|
||||
#=================================================
|
||||
# DEFINE PORT
|
||||
# CONFIGURE ONLYOFFICE
|
||||
#=================================================
|
||||
ynh_print_info "Define OnlyOffice server port..."
|
||||
ynh_print_info --message="Configuring Onlyoffice..."
|
||||
|
||||
echo onlyoffice-documentserver onlyoffice/ds-port select ${port} | sudo debconf-set-selections
|
||||
echo onlyoffice-documentserver onlyoffice/ds-port select $port | sudo debconf-set-selections
|
||||
echo onlyoffice-documentserver onlyoffice/db-host string 127.0.0.1 | sudo debconf-set-selections
|
||||
echo onlyoffice-documentserver onlyoffice/db-user string $db_user | sudo debconf-set-selections
|
||||
echo onlyoffice-documentserver onlyoffice/db-pwd password $db_pwd | debconf-set-selections
|
||||
echo onlyoffice-documentserver onlyoffice/db-name string $db_name | sudo debconf-set-selections
|
||||
|
||||
#=================================================
|
||||
# REINSTALL ONLYOFFICE
|
||||
#=================================================
|
||||
ynh_print_info "Reinstalling OnlyOffice..."
|
||||
ynh_print_info --message="Reinstalling OnlyOffice..."
|
||||
|
||||
wget $source
|
||||
apt install -y ./onlyoffice-documentserver_amd64.deb
|
||||
ynh_add_app_dependencies --package="onlyoffice-documentserver"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info --message="Restoring the configuration..."
|
||||
|
||||
ynh_restore_file --origin_path="/etc/onlyoffice"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_print_info "Reloading nginx web server..."
|
||||
ynh_print_info --message="Reloading nginx web server..."
|
||||
|
||||
systemctl reload nginx
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# RELOAD ONLYOFFICE
|
||||
#=================================================
|
||||
ynh_print_info "Reloading OnlyOffice..."
|
||||
ynh_print_info --message="Reloading OnlyOffice..."
|
||||
|
||||
supervisorctl stop all
|
||||
supervisorctl start all
|
||||
supervisorctl restart all
|
||||
|
||||
sleep 30
|
||||
|
||||
|
@ -157,4 +141,4 @@ sleep 30
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Restoration completed for $app"
|
||||
ynh_print_info --message="Restoration completed for $app"
|
||||
|
|
121
scripts/upgrade
121
scripts/upgrade
|
@ -7,52 +7,50 @@
|
|||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source ynh_add_extra_apt_repos__3
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_print_info "Loading installation settings..."
|
||||
ynh_print_info --message="Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
path_url=$(ynh_app_setting_get $app path)
|
||||
is_public=$(ynh_app_setting_get $app is_public)
|
||||
db_name=$(ynh_app_setting_get $app db_name)
|
||||
port=$(ynh_app_setting_get $app port)
|
||||
nextclouddomain=$(ynh_app_setting_get $app nextclouddomain)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||
is_public=$(ynh_app_setting_get --app=$app --key=is_public)
|
||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||
nextclouddomain=$(ynh_app_setting_get --app=$app --key=nextclouddomain)
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
ynh_print_info "Ensuring downward compatibility..."
|
||||
ynh_print_info --message="Ensuring downward compatibility..."
|
||||
|
||||
# Fix is_public as a boolean value
|
||||
if [ "$is_public" = "Yes" ]; then
|
||||
ynh_app_setting_set $app is_public 1
|
||||
ynh_app_setting_set --app=$app --key=is_public --value=1
|
||||
is_public=1
|
||||
elif [ "$is_public" = "No" ]; then
|
||||
ynh_app_setting_set $app is_public 0
|
||||
ynh_app_setting_set --app=$app --key=is_public --value=0
|
||||
is_public=0
|
||||
fi
|
||||
|
||||
# If db_name doesn't exist, create it
|
||||
if [ -z $db_name ]; then
|
||||
db_name=$(ynh_sanitize_dbid $app)
|
||||
ynh_app_setting_set $app db_name $db_name
|
||||
if [ -z "$db_name" ]; then
|
||||
db_name=$(ynh_sanitize_dbid --db_name=$app)
|
||||
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||
fi
|
||||
|
||||
# If final_path doesn't exist, create it
|
||||
if [ -z $final_path ]; then
|
||||
final_path=/var/www/$app
|
||||
ynh_app_setting_set $app final_path $final_path
|
||||
fi
|
||||
ynh_secure_remove --file="/etc/apt/sources.list.d/onlyoffice.list"
|
||||
ynh_secure_remove --file="/etc/apt/sources.list.d/nodesource.list"
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
ynh_print_info "Backing up the app before upgrading (may take a while)..."
|
||||
ynh_print_info --message="Backing up the app before upgrading (may take a while)..."
|
||||
|
||||
# Backup the current version of the app
|
||||
ynh_backup_before_upgrade
|
||||
|
@ -68,110 +66,119 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
|
||||
# Normalize the URL path syntax
|
||||
path_url=$(ynh_normalize_url_path $path_url)
|
||||
|
||||
path_url=$(ynh_normalize_url_path --path_url=$path_url)
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info "Configuring nginx web server..."
|
||||
ynh_print_info --message="Configuring nginx web server..."
|
||||
|
||||
### `ynh_add_nginx_config` will use the file conf/nginx.conf
|
||||
if [ $path_url = "/" ]; then
|
||||
ynh_replace_string "__SUB_PATH__" "" "../conf/nginx.conf"
|
||||
if [ "$path_url" = "/" ]; then
|
||||
ynh_replace_string --match_string="__SUB_PATH__" --replace_string="" --target_file="../conf/nginx.conf"
|
||||
else
|
||||
ynh_replace_string "__SUB_PATH__" "$path_url" "../conf/nginx.conf"
|
||||
ynh_replace_string --match_string="__SUB_PATH__" --replace_string="$path_url" --target_file="../conf/nginx.conf"
|
||||
fi
|
||||
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config "nextclouddomain"
|
||||
|
||||
# Fix main domain X-Frame-Options
|
||||
ynh_replace_string "X-Frame-Options : SAMEORIGIN" "X-Frame-Options : ALLOW-FROM https://$nextclouddomain" "/etc/nginx/conf.d/$domain.conf"
|
||||
ynh_replace_string --match_string="X-Frame-Options : SAMEORIGIN" --replace_string="X-Frame-Options : ALLOW-FROM https://$nextclouddomain" --target_file="/etc/nginx/conf.d/$domain.conf"
|
||||
|
||||
#=================================================
|
||||
# UPGRADE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_print_info "Upgrading dependencies..."
|
||||
ynh_print_info --message="Upgrading dependencies..."
|
||||
|
||||
ynh_install_app_dependencies postgresql libstdc++6 redis-server rabbitmq-server
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_print_info "Making sure dedicated system user exists..."
|
||||
ynh_print_info --message="Making sure dedicated system user exists..."
|
||||
|
||||
# Create a dedicated user (if not existing)
|
||||
ynh_system_user_create $app $final_path
|
||||
ynh_system_user_create --username=$app
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC UPGRADE
|
||||
#=================================================
|
||||
# ADD NODEJS REPOSITORY
|
||||
#=================================================
|
||||
ynh_print_info "Add nodejs repository..."
|
||||
ynh_print_info --message="Add nodejs repository..."
|
||||
|
||||
curl -sL https://deb.nodesource.com/setup_8.x | sudo bash -
|
||||
ynh_install_extra_repo --repo="deb https://deb.nodesource.com/node_8.x stretch main" --key="https://deb.nodesource.com/gpgkey/nodesource.gpg.key"
|
||||
|
||||
#=================================================
|
||||
# ADD ONLYOFFICE REPOSITORY
|
||||
#=================================================
|
||||
ynh_print_info "Add OnlyOffice repository..."
|
||||
ynh_print_info --message="Add OnlyOffice repository..."
|
||||
|
||||
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CB2DE8E5
|
||||
echo "deb http://download.onlyoffice.com/repo/debian squeeze main" | sudo tee /etc/apt/sources.list.d/onlyoffice.list
|
||||
ynh_install_extra_repo --repo="deb http://download.onlyoffice.com/repo/debian squeeze main" --append
|
||||
|
||||
#=================================================
|
||||
# CONFIGURE ONLYOFFICE
|
||||
#=================================================
|
||||
ynh_print_info --message="Configuring Onlyoffice..."
|
||||
|
||||
ynh_backup_if_checksum_is_different --file="/etc/onlyoffice/documentserver/default.json"
|
||||
echo onlyoffice-documentserver onlyoffice/ds-port select $port | sudo debconf-set-selections
|
||||
echo onlyoffice-documentserver onlyoffice/db-host string 127.0.0.1 | sudo debconf-set-selections
|
||||
echo onlyoffice-documentserver onlyoffice/db-user string $db_user | sudo debconf-set-selections
|
||||
echo onlyoffice-documentserver onlyoffice/db-pwd password $db_pwd | debconf-set-selections
|
||||
echo onlyoffice-documentserver onlyoffice/db-name string $db_name | sudo debconf-set-selections
|
||||
|
||||
#=================================================
|
||||
# UPGRADE ONLYOFFICE
|
||||
#=================================================
|
||||
ynh_print_info "Upgrading OnlyOffice..."
|
||||
ynh_print_info --message="Upgrading OnlyOffice..."
|
||||
|
||||
wget $source
|
||||
apt install -y ./onlyoffice-documentserver_amd64.deb
|
||||
ynh_add_app_dependencies --package="onlyoffice-documentserver"
|
||||
|
||||
#=================================================
|
||||
# MODIFY A CONFIG FILE
|
||||
#=================================================
|
||||
|
||||
ynh_replace_string --match_string="\"rejectUnauthorized\": true" --replace_string="\"rejectUnauthorized\": false" --target_file="/etc/onlyoffice/documentserver/default.json"
|
||||
|
||||
#=================================================
|
||||
# STORE THE CONFIG FILE CHECKSUM
|
||||
#=================================================
|
||||
|
||||
### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
|
||||
### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it.
|
||||
#ynh_backup_if_checksum_is_different "$final_path/CONFIG_FILE"
|
||||
# Recalculate and store the checksum of the file for the next upgrade.
|
||||
#ynh_store_file_checksum "$final_path/CONFIG_FILE"
|
||||
|
||||
ynh_store_file_checksum --file="/etc/onlyoffice/documentserver/default.json"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# SECURE FILES AND DIRECTORIES
|
||||
#=================================================
|
||||
|
||||
# Set permissions on app files
|
||||
#chown -R root: $final_path
|
||||
|
||||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
ynh_print_info "Upgrading SSOwat configuration..."
|
||||
ynh_print_info --message="Upgrading SSOwat configuration..."
|
||||
|
||||
# Make app public if necessary
|
||||
if [ $is_public -eq 1 ]
|
||||
then
|
||||
# unprotected_uris allows SSO credentials to be passed anyway
|
||||
ynh_app_setting_set $app unprotected_uris "/"
|
||||
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_print_info "Reloading nginx web server..."
|
||||
ynh_print_info --message="Reloading nginx web server..."
|
||||
|
||||
systemctl reload nginx
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# RELOAD ONLYOFFICE
|
||||
#=================================================
|
||||
ynh_print_info "Reloading OnlyOffice..."
|
||||
ynh_print_info --message="Reloading OnlyOffice..."
|
||||
|
||||
supervisorctl stop all
|
||||
supervisorctl start all
|
||||
supervisorctl restart all
|
||||
|
||||
sleep 30
|
||||
|
||||
|
@ -179,4 +186,4 @@ sleep 30
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info "Upgrade of $app completed"
|
||||
ynh_print_info --message="Upgrade of $app completed"
|
||||
|
|
294
scripts/ynh_add_extra_apt_repos__3
Normal file
294
scripts/ynh_add_extra_apt_repos__3
Normal file
|
@ -0,0 +1,294 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Pin a repository.
|
||||
#
|
||||
# usage: ynh_pin_repo --package=packages --pin=pin_filter [--priority=priority_value] [--name=name] [--append]
|
||||
# | arg: -p, --package - Packages concerned by the pin. Or all, *.
|
||||
# | arg: -i, --pin - Filter for the pin.
|
||||
# | arg: -p, --priority - Priority for the pin
|
||||
# | arg: -n, --name - Name for the files for this repo, $app as default value.
|
||||
# | arg: -a, --append - Do not overwrite existing files.
|
||||
#
|
||||
# See https://manpages.debian.org/stretch/apt/apt_preferences.5.en.html for information about pinning.
|
||||
#
|
||||
ynh_pin_repo () {
|
||||
# Declare an array to define the options of this helper.
|
||||
local legacy_args=pirna
|
||||
declare -Ar args_array=( [p]=package= [i]=pin= [r]=priority= [n]=name= [a]=append )
|
||||
local package
|
||||
local pin
|
||||
local priority
|
||||
local name
|
||||
local append
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
package="${package:-*}"
|
||||
priority=${priority:-50}
|
||||
name="${name:-$app}"
|
||||
append=${append:-0}
|
||||
|
||||
if [ $append -eq 1 ]
|
||||
then
|
||||
append="tee -a"
|
||||
else
|
||||
append="tee"
|
||||
fi
|
||||
|
||||
mkdir -p "/etc/apt/preferences.d"
|
||||
echo "Package: $package
|
||||
Pin: $pin
|
||||
Pin-Priority: $priority" \
|
||||
| $append "/etc/apt/preferences.d/$name"
|
||||
}
|
||||
|
||||
# Add a repository.
|
||||
#
|
||||
# usage: ynh_add_repo --uri=uri --suite=suite --component=component [--name=name] [--append]
|
||||
# | arg: -u, --uri - Uri of the repository.
|
||||
# | arg: -s, --suite - Suite of the repository.
|
||||
# | arg: -c, --component - Component of the repository.
|
||||
# | arg: -n, --name - Name for the files for this repo, $app as default value.
|
||||
# | arg: -a, --append - Do not overwrite existing files.
|
||||
#
|
||||
# Example for a repo like deb http://forge.yunohost.org/debian/ stretch stable
|
||||
# uri suite component
|
||||
# ynh_add_repo --uri=http://forge.yunohost.org/debian/ --suite=stretch --component=stable
|
||||
#
|
||||
ynh_add_repo () {
|
||||
# Declare an array to define the options of this helper.
|
||||
local legacy_args=uscna
|
||||
declare -Ar args_array=( [u]=uri= [s]=suite= [c]=component= [n]=name= [a]=append )
|
||||
local uri
|
||||
local suite
|
||||
local component
|
||||
local name
|
||||
local append
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
name="${name:-$app}"
|
||||
append=${append:-0}
|
||||
|
||||
if [ $append -eq 1 ]
|
||||
then
|
||||
append="tee -a"
|
||||
else
|
||||
append="tee"
|
||||
fi
|
||||
|
||||
mkdir -p "/etc/apt/sources.list.d"
|
||||
# Add the new repo in sources.list.d
|
||||
echo "deb $uri $suite $component" \
|
||||
| $append "/etc/apt/sources.list.d/$name.list"
|
||||
}
|
||||
|
||||
# Add an extra repository correctly, pin it and get the key.
|
||||
#
|
||||
# usage: ynh_install_extra_repo --repo="repo" [--key=key_url] [--priority=priority_value] [--name=name] [--append]
|
||||
# | arg: -r, --repo - Complete url of the extra repository.
|
||||
# | arg: -k, --key - url to get the public key.
|
||||
# | arg: -p, --priority - Priority for the pin
|
||||
# | arg: -n, --name - Name for the files for this repo, $app as default value.
|
||||
# | arg: -a, --append - Do not overwrite existing files.
|
||||
ynh_install_extra_repo () {
|
||||
# Declare an array to define the options of this helper.
|
||||
local legacy_args=rkpna
|
||||
declare -Ar args_array=( [r]=repo= [k]=key= [p]=priority= [n]=name= [a]=append )
|
||||
local repo
|
||||
local key
|
||||
local priority
|
||||
local name
|
||||
local append
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
name="${name:-$app}"
|
||||
append=${append:-0}
|
||||
key=${key:-0}
|
||||
priority=${priority:-}
|
||||
|
||||
if [ $append -eq 1 ]
|
||||
then
|
||||
append="--append"
|
||||
wget_append="tee -a"
|
||||
else
|
||||
append=""
|
||||
wget_append="tee"
|
||||
fi
|
||||
|
||||
# Split the repository into uri, suite and components.
|
||||
# Remove "deb " at the beginning of the repo.
|
||||
repo="${repo#deb }"
|
||||
|
||||
# Get the uri
|
||||
local uri="$(echo "$repo" | awk '{ print $1 }')"
|
||||
|
||||
# Get the suite
|
||||
local suite="$(echo "$repo" | awk '{ print $2 }')"
|
||||
|
||||
# Get the components
|
||||
local component="${repo##$uri $suite }"
|
||||
|
||||
# Add the repository into sources.list.d
|
||||
ynh_add_repo --uri="$uri" --suite="$suite" --component="$component" --name="$name" $append
|
||||
|
||||
# Pin the new repo with the default priority, so it won't be used for upgrades.
|
||||
# Build $pin from the uri without http and any sub path
|
||||
local pin="${uri#*://}"
|
||||
pin="${pin%%/*}"
|
||||
# Set a priority only if asked
|
||||
if [ -n "$priority" ]
|
||||
then
|
||||
priority="--priority=$priority"
|
||||
fi
|
||||
ynh_pin_repo --package="*" --pin="origin \"$pin\"" $priority --name="$name" $append
|
||||
|
||||
# Get the public key for the repo
|
||||
if [ -n "$key" ]
|
||||
then
|
||||
mkdir -p "/etc/apt/trusted.gpg.d"
|
||||
wget -q "$key" -O - | gpg --dearmor | $wget_append /etc/apt/trusted.gpg.d/$name.gpg > /dev/null
|
||||
fi
|
||||
|
||||
# Update the list of package with the new repo
|
||||
ynh_package_update
|
||||
}
|
||||
|
||||
# Remove an extra repository and the assiociated configuration.
|
||||
#
|
||||
# usage: ynh_remove_extra_repo [--name=name]
|
||||
# | arg: -n, --name - Name for the files for this repo, $app as default value.
|
||||
ynh_remove_extra_repo () {
|
||||
# Declare an array to define the options of this helper.
|
||||
local legacy_args=n
|
||||
declare -Ar args_array=( [n]=name= )
|
||||
local name
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
name="${name:-$app}"
|
||||
|
||||
ynh_secure_remove "/etc/apt/sources.list.d/$name.list"
|
||||
ynh_secure_remove "/etc/apt/preferences.d/$name"
|
||||
ynh_secure_remove "/etc/apt/trusted.gpg.d/$name.gpg"
|
||||
ynh_secure_remove "/etc/apt/trusted.gpg.d/$name.asc"
|
||||
|
||||
# Update the list of package to exclude the old repo
|
||||
ynh_package_update
|
||||
}
|
||||
|
||||
# Install packages from an extra repository properly.
|
||||
#
|
||||
# usage: ynh_install_extra_app_dependencies --repo="repo" --package="dep1 dep2" [--key=key_url] [--name=name]
|
||||
# | arg: -r, --repo - Complete url of the extra repository.
|
||||
# | arg: -p, --package - The packages to install from this extra repository
|
||||
# | arg: -k, --key - url to get the public key.
|
||||
# | arg: -n, --name - Name for the files for this repo, $app as default value.
|
||||
ynh_install_extra_app_dependencies () {
|
||||
# Declare an array to define the options of this helper.
|
||||
local legacy_args=rpkn
|
||||
declare -Ar args_array=( [r]=repo= [p]=package= [k]=key= [n]=name= )
|
||||
local repo
|
||||
local package
|
||||
local key
|
||||
local name
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
name="${name:-$app}"
|
||||
key=${key:-0}
|
||||
|
||||
# Set a key only if asked
|
||||
if [ -n "$key" ]
|
||||
then
|
||||
key="--key=$key"
|
||||
fi
|
||||
# Add an extra repository for those packages
|
||||
ynh_install_extra_repo --repo="$repo" $key --priority=995 --name=$name
|
||||
|
||||
# Install requested dependencies from this extra repository.
|
||||
ynh_add_app_dependencies --package="$package"
|
||||
|
||||
# Remove this extra repository after packages are installed
|
||||
ynh_remove_extra_repo --name=$app
|
||||
}
|
||||
|
||||
#=================================================
|
||||
|
||||
# patched version of ynh_install_app_dependencies to be used with ynh_add_app_dependencies
|
||||
|
||||
# Define and install dependencies with a equivs control file
|
||||
# This helper can/should only be called once per app
|
||||
#
|
||||
# usage: ynh_install_app_dependencies dep [dep [...]]
|
||||
# | arg: dep - the package name to install in dependence
|
||||
# You can give a choice between some package with this syntax : "dep1|dep2"
|
||||
# Example : ynh_install_app_dependencies dep1 dep2 "dep3|dep4|dep5"
|
||||
# This mean in the dependence tree : dep1 & dep2 & (dep3 | dep4 | dep5)
|
||||
#
|
||||
# Requires YunoHost version 2.6.4 or higher.
|
||||
ynh_install_app_dependencies () {
|
||||
local dependencies=$@
|
||||
dependencies="$(echo "$dependencies" | sed 's/\([^\<=\>]\)\ \([^(]\)/\1, \2/g')"
|
||||
dependencies=${dependencies//|/ | }
|
||||
local manifest_path="../manifest.json"
|
||||
if [ ! -e "$manifest_path" ]; then
|
||||
manifest_path="../settings/manifest.json" # Into the restore script, the manifest is not at the same place
|
||||
fi
|
||||
|
||||
local version=$(grep '\"version\": ' "$manifest_path" | cut -d '"' -f 4) # Retrieve the version number in the manifest file.
|
||||
if [ ${#version} -eq 0 ]; then
|
||||
version="1.0"
|
||||
fi
|
||||
local dep_app=${app//_/-} # Replace all '_' by '-'
|
||||
|
||||
# Handle specific versions
|
||||
if [[ "$dependencies" =~ [\<=\>] ]]
|
||||
then
|
||||
# Replace version specifications by relationships syntax
|
||||
# https://www.debian.org/doc/debian-policy/ch-relationships.html
|
||||
# Sed clarification
|
||||
# [^(\<=\>] ignore if it begins by ( or < = >. To not apply twice.
|
||||
# [\<=\>] matches < = or >
|
||||
# \+ matches one or more occurence of the previous characters, for >= or >>.
|
||||
# [^,]\+ matches all characters except ','
|
||||
# Ex: package>=1.0 will be replaced by package (>= 1.0)
|
||||
dependencies="$(echo "$dependencies" | sed 's/\([^(\<=\>]\)\([\<=\>]\+\)\([^,]\+\)/\1 (\2 \3)/g')"
|
||||
fi
|
||||
|
||||
cat > /tmp/${dep_app}-ynh-deps.control << EOF # Make a control file for equivs-build
|
||||
Section: misc
|
||||
Priority: optional
|
||||
Package: ${dep_app}-ynh-deps
|
||||
Version: ${version}
|
||||
Depends: ${dependencies}
|
||||
Architecture: all
|
||||
Description: Fake package for $app (YunoHost app) dependencies
|
||||
This meta-package is only responsible of installing its dependencies.
|
||||
EOF
|
||||
ynh_package_install_from_equivs /tmp/${dep_app}-ynh-deps.control \
|
||||
|| ynh_die --message="Unable to install dependencies" # Install the fake package and its dependencies
|
||||
rm /tmp/${dep_app}-ynh-deps.control
|
||||
ynh_app_setting_set --app=$app --key=apt_dependencies --value="$dependencies"
|
||||
}
|
||||
|
||||
ynh_add_app_dependencies () {
|
||||
# Declare an array to define the options of this helper.
|
||||
local legacy_args=pr
|
||||
declare -Ar args_array=( [p]=package= [r]=replace)
|
||||
local package
|
||||
local replace
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
replace=${replace:-0}
|
||||
|
||||
local current_dependencies=""
|
||||
if [ $replace -eq 0 ]
|
||||
then
|
||||
local dep_app=${app//_/-} # Replace all '_' by '-'
|
||||
if ynh_package_is_installed --package="${dep_app}-ynh-deps"
|
||||
then
|
||||
current_dependencies="$(dpkg-query --show --showformat='${Depends}' ${dep_app}-ynh-deps) "
|
||||
fi
|
||||
|
||||
current_dependencies=${current_dependencies// | /|}
|
||||
fi
|
||||
|
||||
ynh_install_app_dependencies "${current_dependencies}${package}"
|
||||
}
|
Loading…
Add table
Reference in a new issue