From 13fec5955ec9c0efa6357e580c18b56eaf57f75b Mon Sep 17 00:00:00 2001 From: Kay0u Date: Wed, 7 Jul 2021 12:08:04 +0200 Subject: [PATCH] remove some warnings --- check_process | 2 +- scripts/_common.sh | 94 +--------------------------------------------- scripts/install | 2 +- scripts/upgrade | 18 +++++++-- 4 files changed, 18 insertions(+), 98 deletions(-) diff --git a/check_process b/check_process index 96ed247..40e8bbc 100644 --- a/check_process +++ b/check_process @@ -40,7 +40,7 @@ pihole_version="Last 3.X" ; Checks setup_sub_dir=1 - setup_root=0 + setup_root=1 upgrade=1 upgrade=1 from_commit=d79ec131b3038ff4695c3317b5d3ee4eda9c8932 backup_restore=1 diff --git a/scripts/_common.sh b/scripts/_common.sh index 5c8cf50..8d3534c 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,83 +4,6 @@ # FUTUR OFFICIAL HELPERS #================================================= -# Install or update the main directory yunohost.multimedia -# -# usage: ynh_multimedia_build_main_dir -ynh_multimedia_build_main_dir () { - local ynh_media_release="v1.2" - local checksum="806a827ba1902d6911095602a9221181" - - # Download yunohost.multimedia scripts - wget -nv https://github.com/YunoHost-Apps/yunohost.multimedia/archive/${ynh_media_release}.tar.gz - - # Check the control sum - echo "${checksum} ${ynh_media_release}.tar.gz" | md5sum -c --status \ - || ynh_die "Corrupt source" - - # Check if the package acl is installed. Or install it. - ynh_package_is_installed 'acl' \ - || ynh_package_install acl - - # Extract - mkdir yunohost.multimedia-master - tar -xf ${ynh_media_release}.tar.gz -C yunohost.multimedia-master --strip-components 1 - ./yunohost.multimedia-master/script/ynh_media_build.sh -} - -# Add a directory in yunohost.multimedia -# This "directory" will be a symbolic link to a existing directory. -# -# usage: ynh_multimedia_addfolder "Source directory" "Destination directory" -# -# | arg: -s, --source_dir= - Source directory - The real directory which contains your medias. -# | arg: -d, --dest_dir= - Destination directory - The name and the place of the symbolic link, relative to "/home/yunohost.multimedia" -ynh_multimedia_addfolder () { - # Declare an array to define the options of this helper. - declare -Ar args_array=( [s]=source_dir= [d]=dest_dir= ) - local source_dir - local dest_dir - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - - ./yunohost.multimedia-master/script/ynh_media_addfolder.sh --source="$source_dir" --dest="$dest_dir" -} - -# Move a directory in yunohost.multimedia, and replace by a symbolic link -# -# usage: ynh_multimedia_movefolder "Source directory" "Destination directory" -# -# | arg: -s, --source_dir= - Source directory - The real directory which contains your medias. -# It will be moved to "Destination directory" -# A symbolic link will replace it. -# | arg: -d, --dest_dir= - Destination directory - The new name and place of the directory, relative to "/home/yunohost.multimedia" -ynh_multimedia_movefolder () { - # Declare an array to define the options of this helper. - declare -Ar args_array=( [s]=source_dir= [d]=dest_dir= ) - local source_dir - local dest_dir - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - - ./yunohost.multimedia-master/script/ynh_media_addfolder.sh --inv --source="$source_dir" --dest="$dest_dir" -} - -# Allow an user to have an write authorisation in multimedia directories -# -# usage: ynh_multimedia_addaccess user_name -# -# | arg: -u, --user_name= - The name of the user which gain this access. -ynh_multimedia_addaccess () { - # Declare an array to define the options of this helper. - declare -Ar args_array=( [u]=user_name=) - local user_name - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - - groupadd -f multimedia - usermod -a -G multimedia $user_name -} - #================================================= # EXPERIMENTAL HELPERS #================================================= @@ -441,19 +364,4 @@ ynh_app_changelog () { then echo "No significative changes from the changelog..." > "${final_changelog}_lite" fi -} - -#================================================= - -# Execute a command as another user -# usage: exec_as USER COMMAND [ARG ...] -ynh_exec_as() { - local USER=$1 - shift 1 - - if [[ $USER = $(whoami) ]]; then - eval "$@" - else - sudo -u "$USER" "$@" - fi -} +} \ No newline at end of file diff --git a/scripts/install b/scripts/install index a545390..620da12 100644 --- a/scripts/install +++ b/scripts/install @@ -455,7 +455,7 @@ yunohost service add pihole-FTL --description "PiHole backend service" --log "/v #================================================= ynh_script_progression --message="Restraining the access to the admin only..." --weight=2 -yunohost app addaccess --users=$admin $app +ynh_permission_update --permission="main" --add="$admin" --remove="all_users" #================================================= # RELOAD NGINX diff --git a/scripts/upgrade b/scripts/upgrade index 6b05774..2d5b20a 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -295,11 +295,17 @@ else ynh_exec_warn_less systemctl disable dnsmasq # And move the files that make the service available in systemd to really disable it - mv /lib/systemd/system/dnsmasq.service /lib/systemd/system/.dnsmasq.service.backup_by_pihole - mv /etc/init.d/dnsmasq /etc/init.d/.dnsmasq.backup_by_pihole + if [ ! -e "/lib/systemd/system/.dnsmasq.service.backup_by_pihole" ]; then + mv /lib/systemd/system/dnsmasq.service /lib/systemd/system/.dnsmasq.service.backup_by_pihole + fi + if [ ! -e "/etc/init.d/.dnsmasq.backup_by_pihole" ]; then + mv /etc/init.d/dnsmasq /etc/init.d/.dnsmasq.backup_by_pihole + fi # Move dnsmasq to preserve the current binary - mv /usr/sbin/dnsmasq /usr/sbin/dnsmasq.backup_by_pihole + if [ ! -e "/usr/sbin/dnsmasq.backup_by_pihole" ]; then + mv /usr/sbin/dnsmasq /usr/sbin/dnsmasq.backup_by_pihole + fi # Replace dnsmasq by pihole-FTL # NOTE: pihole-FTL is actually a modified version of dnsmasq # https://github.com/pi-hole/FTL/tree/master/dnsmasq @@ -368,6 +374,12 @@ ynh_script_progression --message="Restarting PiHole-FTL..." --weight=2 ynh_systemd_action --action=restart --service_name=pihole-FTL +#================================================= +# ADVERTISE SERVICE IN ADMIN PANEL +#================================================= + +yunohost service add pihole-FTL --description "PiHole backend service" --log "/var/log/pihole-FTL.log" + #================================================= # UPDATE CONF_REGEN HOOK #=================================================