Skip to content

Commit

Permalink
Merge pull request YunoHost#79 from YunoHost/getops
Browse files Browse the repository at this point in the history
Getops
  • Loading branch information
maniackcrudelis authored Apr 18, 2019
2 parents 0e702da + 0f96833 commit 7e7e342
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 141 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"url": "http://example.com"
},
"requirements": {
"yunohost": ">= 3.4"
"yunohost": ">= 3.5"
},
"multi_instance": true,
"services": [
Expand Down
36 changes: 18 additions & 18 deletions scripts/backup
Original file line number Diff line number Diff line change
Expand Up @@ -24,68 +24,68 @@ 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)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
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_print_info --message="Backing up the main app directory..."

ynh_backup "$final_path"
ynh_backup --src_path="$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 PHP-FPM CONFIGURATION
#=================================================
ynh_print_info "Backing up php-fpm configuration..."
ynh_print_info --message="Backing up php-fpm configuration..."

ynh_backup "/etc/php/7.0/fpm/pool.d/$app.conf"
ynh_backup --src_path="/etc/php/7.0/fpm/pool.d/$app.conf"

#=================================================
# BACKUP THE MYSQL DATABASE
#=================================================
ynh_print_info "Backing up the MySQL database..."
ynh_print_info --message="Backing up the MySQL database..."

ynh_mysql_dump_db "$db_name" > db.sql
ynh_mysql_dump_db --database="$db_name" > db.sql

#=================================================
# SPECIFIC BACKUP
#=================================================
# BACKUP LOGROTATE
#=================================================
ynh_print_info "Backing up logrotate configuration..."
ynh_print_info --message="Backing up logrotate configuration..."

ynh_backup "/etc/logrotate.d/$app"
ynh_backup --src_path="/etc/logrotate.d/$app"

#=================================================
# BACKUP SYSTEMD
#=================================================
ynh_print_info "Backing up systemd configuration..."
ynh_print_info --message="Backing up systemd configuration..."

ynh_backup "/etc/systemd/system/$app.service"
ynh_backup --src_path="/etc/systemd/system/$app.service"

#=================================================
# BACKUP A CRON FILE
#=================================================

ynh_backup "/etc/cron.d/$app"
ynh_backup --src_path="/etc/cron.d/$app"

#=================================================
# 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)."
20 changes: 10 additions & 10 deletions scripts/change_url
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ 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)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)

# 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)
#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
Expand All @@ -54,15 +54,15 @@ 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

# Change the path in the nginx config file
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"
Expand All @@ -74,10 +74,10 @@ 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_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi

#=================================================
Expand All @@ -91,12 +91,12 @@ fi
#=================================================
# RELOAD NGINX
#=================================================
ynh_print_info "Reloading nginx web server..."
ynh_print_info --message="Reloading nginx web server..."

systemctl reload nginx

#=================================================
# END OF SCRIPT
#=================================================

ynh_print_info "Change of URL completed for $app"
ynh_print_info --message="Change of URL completed for $app"
66 changes: 33 additions & 33 deletions scripts/install
Original file line number Diff line number Diff line change
Expand Up @@ -46,33 +46,33 @@ app=$YNH_APP_INSTANCE_NAME
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_print_info "Validating installation parameters..."
ynh_print_info --message="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"

# 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 admin $admin
ynh_app_setting_set $app is_public $is_public
ynh_app_setting_set $app language $language
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=admin --value=$admin
ynh_app_setting_set --app=$app --key=is_public --value=$is_public
ynh_app_setting_set --app=$app --key=language --value=$language

#=================================================
# STANDARD MODIFICATIONS
#=================================================
# FIND AND OPEN A PORT
#=================================================
ynh_print_info "Configuring firewall..."
ynh_print_info --message="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.
Expand All @@ -83,12 +83,12 @@ ynh_print_info "Configuring firewall..."
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
ynh_app_setting_set --app=$app --key=port --value=$port

#=================================================
# 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.
Expand All @@ -103,7 +103,7 @@ ynh_install_app_dependencies $pkg_dependencies
#=================================================
# CREATE A MYSQL DATABASE
#=================================================
ynh_print_info "Creating a MySQL database..."
ynh_print_info --message="Creating a MySQL 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.
Expand All @@ -115,26 +115,26 @@ ynh_print_info "Creating a MySQL database..."
### - As well as the section "RESTORE THE MYSQL DATABASE" in the restore script

db_name=$(ynh_sanitize_dbid $app)
ynh_app_setting_set $app db_name $db_name
ynh_mysql_setup_db $db_name $db_name
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name

#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_print_info "Setting up source files..."
ynh_print_info --message="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
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source "$final_path"
ynh_setup_source --dest_dir="$final_path"

#=================================================
# 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

Expand All @@ -144,15 +144,15 @@ ynh_add_nginx_config
#=================================================
# 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
ynh_system_user_create --username=$app

#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_print_info "Configuring php-fpm..."
ynh_print_info --message="Configuring php-fpm..."

### `ynh_add_fpm_config` is used to set up a PHP config.
### You can remove it if your app doesn't use PHP.
Expand All @@ -177,7 +177,7 @@ ynh_add_fpm_config
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_print_info "Configuring a systemd service..."
ynh_print_info --message="Configuring a systemd service..."

### `ynh_systemd_config` is used to configure a systemd script for an app.
### It can be used for apps that use sysvinit (with adaptation) or systemd.
Expand Down Expand Up @@ -206,22 +206,22 @@ ynh_add_systemd_config
chown -R $app: $final_path

# Set the app as temporarily public for curl call
ynh_print_info "Configuring SSOwat..."
ynh_app_setting_set $app skipped_uris "/"
ynh_print_info --message="Configuring SSOwat..."
ynh_app_setting_set --app=$app --key=skipped_uris --value="/"
# Reload SSOwat config
yunohost app ssowatconf

# Reload Nginx
systemctl reload nginx

# Installation with curl
ynh_print_info "Finalizing installation..."
ynh_print_info --message="Finalizing installation..."
ynh_local_curl "/INSTALL_PATH" "key1=value1" "key2=value2" "key3=value3"

# Remove the public access
if [ $is_public -eq 0 ]
then
ynh_app_setting_delete $app skipped_uris
ynh_app_setting_delete --app=$app --key=skipped_uris
fi

#=================================================
Expand All @@ -231,7 +231,7 @@ fi
### `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="match_string" --replace_string="replace_string" --target_file="$final_path/CONFIG_FILE"

#=================================================
# STORE THE CONFIG FILE CHECKSUM
Expand All @@ -242,7 +242,7 @@ ynh_replace_string "match_string" "replace_string" "$final_path/CONFIG_FILE"
### 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 "$final_path/CONFIG_FILE"
ynh_store_file_checksum --file="$final_path/CONFIG_FILE"

#=================================================
# GENERIC FINALIZATION
Expand All @@ -260,7 +260,7 @@ chown -R root: $final_path
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_print_info "Configuring log rotation..."
ynh_print_info --message="Configuring log rotation..."

### `ynh_use_logrotate` is used to configure a logrotate configuration for the logs of this app.
### Use this helper only if there is effectively a log file for this app.
Expand Down Expand Up @@ -292,24 +292,24 @@ yunohost service add $app --log "/var/log/$app/$app.log"
#=================================================
# 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

#=================================================
# END OF SCRIPT
#=================================================

ynh_print_info "Installation of $app completed"
ynh_print_info --message="Installation of $app completed"
Loading

0 comments on commit 7e7e342

Please sign in to comment.