mirror of
https://github.com/YunoHost-Apps/openproject_ynh.git
synced 2024-09-03 19:56:10 +02:00
Adding quiet, infos verbosity
This commit is contained in:
parent
bead79c1db
commit
cf0f4d9686
9 changed files with 140 additions and 13 deletions
|
@ -15,7 +15,7 @@
|
|||
"url": "http://jserv.fr"
|
||||
},
|
||||
"requirements": {
|
||||
"yunohost": ">= 3.4"
|
||||
"yunohost": ">= 3.6"
|
||||
},
|
||||
"multi_instance": false,
|
||||
"services": [
|
||||
|
|
|
@ -11,10 +11,45 @@ export pkg_dependencies="apt-transport-https memcached openproject postgresql po
|
|||
# PERSONAL HELPERS
|
||||
#=================================================
|
||||
|
||||
# Checks if string existin a file, or add it.
|
||||
ynh_string_in_file () {
|
||||
# Declare an array to define the options of this helper.
|
||||
local legacy_args=msf
|
||||
declare -Ar args_array=( [m]=match_string= [s]=string= [f]=target_file= )
|
||||
local match_string
|
||||
local string
|
||||
local target_file
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
|
||||
local delimit=@
|
||||
# Escape the delimiter if it's in the string.
|
||||
if grep "$match_string" $target_file; then
|
||||
else
|
||||
echo $string >
|
||||
fi
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# EXPERIMENTAL HELPERS
|
||||
#=================================================
|
||||
|
||||
source ynh_add_extra_apt_repos
|
||||
|
||||
# Execute a command as another user
|
||||
# usage: ynh_exec_as USER COMMAND [ARG ...]
|
||||
ynh_exec_as() {
|
||||
local USER=$1
|
||||
shift 1
|
||||
|
||||
if [[ $USER = $(whoami) ]]; then
|
||||
eval "$@"
|
||||
else
|
||||
# use sudo twice to be root and be allowed to use another user
|
||||
sudo sudo -u "$USER" "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# FUTURE OFFICIAL HELPERS
|
||||
#=================================================
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#=================================================
|
||||
|
||||
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||
source _common.sh
|
||||
source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -29,6 +29,8 @@ ynh_script_progression --message="Loading installation settings..." --time --wei
|
|||
# Needed for helper "ynh_add_nginx_config"
|
||||
final_path=$(ynh_app_setting_get --app="$app" --key=final_path)
|
||||
export final_path
|
||||
port=$(ynh_app_setting_get --app="$app" --key=port)
|
||||
export port
|
||||
|
||||
#=================================================
|
||||
# CHECK WHICH PARTS SHOULD BE CHANGED
|
||||
|
|
|
@ -30,11 +30,6 @@ final_path="/var/www/$app"
|
|||
_homedir="/var/$app/"
|
||||
_openproject_install_dat="/etc/openproject/installer.dat"
|
||||
|
||||
# Find a free port.
|
||||
# This will only be used:
|
||||
# - By OpenProject to fire app server listening to this port, and
|
||||
# - Nginx to proxify on this.
|
||||
port=$(ynh_find_port --port=6000)
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||
|
@ -43,6 +38,12 @@ ynh_script_progression --message="Validating installation parameters..." --weigh
|
|||
|
||||
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
||||
|
||||
# Find a free port.
|
||||
# This will only be used:
|
||||
# - By OpenProject to fire app server listening to this port, and
|
||||
# - Nginx to proxify on this.
|
||||
port=$(ynh_find_port --port=6000)
|
||||
|
||||
# Register (book) web path
|
||||
ynh_webpath_register --app="$app" --domain="$domain" --path_url="$path_url"
|
||||
|
||||
|
@ -82,10 +83,10 @@ ynh_script_progression --message="Installing OpenProject & its dependencies..."
|
|||
|
||||
# Add Openproject Key & repo
|
||||
# Var APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE to disable the STDOUT redirection warning
|
||||
wget -qO- https://dl.packager.io/srv/opf/openproject/key | sudo APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1 apt-key add - >/dev/null
|
||||
wget -qO /etc/apt/sources.list.d/openproject.list https://dl.packager.io/srv/opf/openproject/stable/10/installer/debian/9.repo
|
||||
wget -qO- https://dl.packager.io/srv/opf/openproject/key | APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1 apt-key add - >/dev/null
|
||||
wget -qO /etc/apt/sources.list.d/openproject.list https://dl.packager.io/srv/opf/openproject/stable/10/installer/debian/9.repo
|
||||
|
||||
ynh_install_app_dependencies "$pkg_dependencies"
|
||||
ynh_install_app_dependencies "$pkg_dependencies" >> "$YNH_STDINFO"
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
|
@ -123,7 +124,7 @@ EOF
|
|||
ynh_store_file_checksum --file="$_openproject_install_dat"
|
||||
|
||||
|
||||
ynh_replace_string --match_string=".*PORT=.*" --replace_string="export port=$port" --target_file="/etc/default/openproject"
|
||||
ynh_replace_string --match_string=".*PORT=.*" --replace_string="export PORT=$port" --target_file="/etc/default/openproject"
|
||||
|
||||
#=================================================
|
||||
# CREATE A POSTGRESQL DATABASE
|
||||
|
@ -140,7 +141,7 @@ ynh_psql_create_db "$db_name" "$db_user" "$db_pwd"
|
|||
|
||||
ynh_script_progression --message="Post-install of OpenProject" --weight=1
|
||||
|
||||
openproject configure
|
||||
openproject configure >> "$YNH_STDINFO"
|
||||
|
||||
####=================================================
|
||||
#### SETUP APPLICATION WITH CURL
|
||||
|
|
|
@ -68,6 +68,7 @@ ynh_script_progression --message="Removing app main directory..." --weight=1
|
|||
ynh_secure_remove --file="$final_path"
|
||||
ynh_secure_remove --file="$_homedir"
|
||||
ynh_secure_remove --file="/etc/$app/"
|
||||
ynh_secure_remove --file="/etc/apt/sources.list.d/openproject.list"
|
||||
|
||||
#=================================================
|
||||
# REMOVE NGINX CONFIGURATION
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#=================================================
|
||||
|
||||
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||
source _common.sh
|
||||
source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
ynh_abort_if_errors
|
||||
|
||||
|
|
88
scripts/ynh_add_extra_apt_repos
Normal file
88
scripts/ynh_add_extra_apt_repos
Normal file
|
@ -0,0 +1,88 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Helper to add a repos quickly and without problem. It create a repos.list in $etc/apt/sources.list.d/. It doesn't update the repos, so it must be used with the ynh_add_dependencies.
|
||||
# usage : ynh_add_repos nameoftherepos url
|
||||
# URL IS SOMETHING LIKE : "deb $mirrorurl $prefix(stable or jessie...) $otherprefix(main, non-free, or somting like that)"
|
||||
ynh_add_repo(){
|
||||
local name_repos="$1"
|
||||
local url_repos="$2"
|
||||
echo "# $name_repos
|
||||
${url_repos}"
|
||||
> "/etc/apt/sources.list.d/$name_repos.list"
|
||||
}
|
||||
|
||||
# Helper to pin a repos easily.
|
||||
# usage : ynh_add_pin_repo nameoftherepos nbrofthepin origin
|
||||
# Origin is the name of the orga which set up this repos ex: Debian
|
||||
ynh_add_pin_repo() {
|
||||
local name_repos="$1"
|
||||
local pin="$2"
|
||||
local origin="$3"
|
||||
echo "Package: *
|
||||
Pin: release o=$origin,a=$name_repos
|
||||
Pin-Priority: $pin" \
|
||||
> "/etc/apt/preferences.d/$name_repos"
|
||||
}
|
||||
|
||||
# Add in a secure way backports repo.
|
||||
# usage : ynh_add_secure_backport
|
||||
ynh_add_secure_backport() {
|
||||
local name_repos="debian-backports"
|
||||
local origin="Debian"
|
||||
local lsb_version="$(ynh_get_debian_release)"
|
||||
local url="deb https://ftp.debian.org/debian $lsb_version-backports main"
|
||||
local pin="450"
|
||||
ynh_add_repos $name_repos $url
|
||||
ynh_add_pin_repo $name_repos $origin $pin
|
||||
}
|
||||
|
||||
# Remove a repos easily in a secure way using the ynh_secure_remove helper
|
||||
ynh_rm_secure_repos() {
|
||||
local name_repos=$1
|
||||
ynh_secure_remove "/etc/apt/preferences.d/$name_repos"
|
||||
ynh_secure_remove "/etc/apt/sources.list.d/$name_repos.list"
|
||||
}
|
||||
|
||||
# Backup the repo
|
||||
ynh_backup_repo() {
|
||||
local name_repo=$1
|
||||
ynh_backup "/etc/apt/preference.d/$name_repo"
|
||||
ynh_backup "/etc/apt/sources.list.d/$name_repo.list"
|
||||
}
|
||||
|
||||
ynh_restore_repo() {
|
||||
local name_repo=$1
|
||||
local custom_arch=$2
|
||||
ynh_restore "/etc/apt/preference.d/$name_repo"
|
||||
if [[ custom_arch -ne true ]]
|
||||
local arch_system=$(lsb_release -c)
|
||||
arch_system=$(echo ${arch#Codename:})
|
||||
same_arch=$(cat $name_repo | grep $arch)
|
||||
archs = [jessie, stretch, buster]
|
||||
ynh_restore "/etc/apt/sources.list.d/$name_repo.list"
|
||||
for arch in archs
|
||||
do
|
||||
same_arch=$(cat $name_repo | grep $arch)
|
||||
if [[ same_arch -e arch ]]
|
||||
then
|
||||
echo "Everything is ok"
|
||||
else
|
||||
sed -i "s@$arch@$arch_system@g" "/etc/apt/sources.list.d/$name_repo.list"
|
||||
fi
|
||||
done
|
||||
else
|
||||
echo "Attention: vous avez choisi de personnaliser votre header"
|
||||
ynh_restore "/etc/apt/sources.list.d/$name_repo.list"
|
||||
fi
|
||||
}
|
||||
|
||||
ynh_backup_all_repos() {
|
||||
if [[ $(ls /etc/apt/preference.d/) -ne "" ]]
|
||||
then
|
||||
ynh_backup "/etc/apt/preference.d/*"
|
||||
fi
|
||||
if [[ $(ls /eyc/apt/sources.list.d/) -ne "" ]]
|
||||
then
|
||||
ynh_backup "/etc/apt/sources.list.d/*"
|
||||
fi
|
||||
}
|
0
test
Normal file
0
test
Normal file
Loading…
Reference in a new issue