| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- #!/bin/bash
- #=================================================
- # IMPORT GENERIC HELPERS
- #=================================================
- source _common.sh
- source /usr/share/yunohost/helpers
- #=================================================
- # INITIALIZE AND STORE SETTINGS
- #=================================================
- if [ "$encrypt" -eq 1 ] && [ -z "$encryption_pwd" ]; then
- ynh_die "encryption_pwd can't be empty if you choose to enable encryption."
- fi
- # Not saved as settings by default
- ynh_app_setting_set --key="encryption_pwd" --value="$encryption_pwd"
- _set_frequencies
- ynh_app_setting_set --key=overwrite_cron --value=1
- #=================================================
- # DOWNLOAD, CHECK AND UNPACK SOURCE
- #=================================================
- ynh_script_progression "Setting up source files..."
- # Download, check integrity, uncompress and patch the source from app.src
- ynh_setup_source --dest_dir="$install_dir"
- #REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "root:root" "$install_dir"
- chown -R "root:root" "$data_dir"
- #=================================================
- # CONFIGURE ARCHIVIST
- #=================================================
- ynh_script_progression "Configuring Archivist..."
- if [ "$encrypt" -eq 1 ]; then
- encrypt=true
- passkey="$install_dir/passkey"
- echo "$encryption_pwd" > "$passkey"
- chmod 400 "$passkey"
- else
- encrypt=false
- passkey=na
- fi
- if [ "$core_backup" -eq 1 ]; then
- core_backup=true
- else
- core_backup=false
- fi
- config_file="$install_dir/Backup_list.conf"
- cp "$install_dir/Backup_list.conf.default" "$config_file"
- ynh_replace --file="$config_file" --match="^backup_dir=.*" --replace="backup_dir=$data_dir/backup"
- ynh_replace --file="$config_file" --match="^enc_backup_dir=.*" --replace="enc_backup_dir=$data_dir/encrypted_backup"
- ynh_replace --file="$config_file" --match="^encrypt=.*" --replace="encrypt=$encrypt"
- ynh_replace --file="$config_file" --match="^cryptpass=.*" --replace="cryptpass=$passkey"
- ynh_replace --file="$config_file" --match="^ynh_core_backup=.*" --replace="ynh_core_backup=$core_backup"
- if [ $apps_backup -eq 1 ]; then
- # Add all current applications to the backup
- while read -r backup_app; do
- ynh_replace --file="$config_file" --match="^ynh_app_backup=$" --replace="ynh_app_backup=$backup_app\n&"
- done <<< "$(yunohost app list | grep 'id:' | sed 's/.*id: //')"
- fi
- # Calculate and store the config file checksum into the app settings
- ynh_store_file_checksum "$config_file"
- #=================================================
- # SYSTEM CONFIGURATION
- #=================================================
- ynh_script_progression "Adding system configurations related to $app..."
- # Use logrotate to manage application logfile(s)
- ynh_config_add_logrotate
- # Add Cron configuration file
- ynh_config_add --template="archivist.cron" --destination="/etc/cron.d/$app"
- #=================================================
- # END OF SCRIPT
- #=================================================
- ynh_script_progression "Installation of $app completed"
|