From 77a23bdc41657f0113946e2b99ae4099d981d678 Mon Sep 17 00:00:00 2001 From: Marco Raber Date: Sat, 9 Apr 2022 15:01:41 +0200 Subject: [PATCH] Makefile risolve tilde, programma puoi impostare quale programma per su --- Makefile | 4 ++-- ne | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 234fb74..a57fafd 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ # See LICENSE file for copyright and license details. # paths -PREFIX = ~/.local +PREFIX = /home/${USER}/.local MANPREFIX = $(PREFIX)/share/man SHELL = bash @@ -19,7 +19,7 @@ install: #problema del check: in PATH si trova estesa, qua e' con ~ #echo "${PATH}" | grep -q "$(DESTDIR)$(PREFIX)/bin" || echo "$(DESTDIR)$(PREFIX)/bin is not in the PATH variable, ne won't run" - +#(echo ${PATH} | grep -q $(PREFIX)/bin) || echo "$(DESTDIR)$(PREFIX)/bin is not in the PATH variable, ne won't run" uninstall: rm -f $(DESTDIR)$(PREFIX)/bin/ne diff --git a/ne b/ne index a938219..7ee330c 100755 --- a/ne +++ b/ne @@ -9,6 +9,7 @@ usage() { echo "-h -> Show this help" echo "-y -> skip confirm on reload" echo "-c -> manually choose the text editor (default = vim)" + echo "Note: ne chooses sudo by default, to change this behaviour update the file ~/.local/share/ne/program_privileges" echo "Default behaviour: without arguments edits nginx.conf with confirmation" exit 0 } @@ -31,7 +32,7 @@ else [[ -e $1 ]] && file=$1 && shift fi [[ $1 = "-y" ]] && shift && skip_confirm=1 -[[ -e ~/.local/share/ne_auto_confirm ]] && skip_confirm=1 #se flag -y in seconda posizione o esiste ~/.local/share/ne_auto_confirm +[[ -e ~/.local/share/ne/settings/auto_confirm ]] && skip_confirm=1 #se flag -y in seconda posizione o esiste ~/.local/share/ne_auto_confirm $(which cp) $file /tmp/copia_check_nginx_${USER} #$(which cat) $file > /tmp/copia_check_nginx_${USER} #non so se usare cat > o cp #se cat > o cp danno errore vuol dire che il file non esiste ed esco male: @@ -50,14 +51,15 @@ then fi [[ -e $(which $text_editor) ]] || exit 3 -sudo $text_editor $file +[[ -e ~/.local/share/ne/settings/program_privileges ]] && program_privileges=$(cat ~/.local/share/ne/settings/program_privileges) || program_privileges=sudo +$program_privileges $text_editor $file diff --color=always $file /tmp/copia_check_nginx_${USER} edited=$? if [[ $edited = 1 ]] then - sudo nginx -t || exit 1 - [[ $skip_confirm = 1 ]] && sudo nginx -s reload || confirm "Configuration OK, reload conf? " && sudo nginx -s reload && echo "nginx should be updated" || echo "Aborted" + $program_privileges nginx -t || exit 1 + [[ $skip_confirm = 1 ]] && $program_privileges nginx -s reload || confirm "Configuration OK, reload conf? " && $program_privileges nginx -s reload && echo "nginx should be updated" || echo "Aborted" else echo "No edits found, no need for nginx reload" exit 1