Makefile risolve tilde, programma puoi impostare quale programma per su

This commit is contained in:
Marco Raber 2022-04-09 15:01:41 +02:00
parent d0ccb1c16d
commit 77a23bdc41
2 changed files with 8 additions and 6 deletions

View File

@ -2,7 +2,7 @@
# See LICENSE file for copyright and license details. # See LICENSE file for copyright and license details.
# paths # paths
PREFIX = ~/.local PREFIX = /home/${USER}/.local
MANPREFIX = $(PREFIX)/share/man MANPREFIX = $(PREFIX)/share/man
SHELL = bash SHELL = bash
@ -19,7 +19,7 @@ install:
#problema del check: in PATH si trova estesa, qua e' con ~ #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 "$(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: uninstall:
rm -f $(DESTDIR)$(PREFIX)/bin/ne rm -f $(DESTDIR)$(PREFIX)/bin/ne

10
ne
View File

@ -9,6 +9,7 @@ usage() {
echo "-h -> Show this help" echo "-h -> Show this help"
echo "-y -> skip confirm on reload" echo "-y -> skip confirm on reload"
echo "-c -> manually choose the text editor (default = vim)" 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" echo "Default behaviour: without arguments edits nginx.conf with confirmation"
exit 0 exit 0
} }
@ -31,7 +32,7 @@ else
[[ -e $1 ]] && file=$1 && shift [[ -e $1 ]] && file=$1 && shift
fi fi
[[ $1 = "-y" ]] && shift && skip_confirm=1 [[ $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 $(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: #se cat > o cp danno errore vuol dire che il file non esiste ed esco male:
@ -50,14 +51,15 @@ then
fi fi
[[ -e $(which $text_editor) ]] || exit 3 [[ -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} diff --color=always $file /tmp/copia_check_nginx_${USER}
edited=$? edited=$?
if [[ $edited = 1 ]] if [[ $edited = 1 ]]
then then
sudo nginx -t || exit 1 $program_privileges 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" [[ $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 else
echo "No edits found, no need for nginx reload" echo "No edits found, no need for nginx reload"
exit 1 exit 1