Files
bashrc/lock_unlock_bashrc.sh
2025-08-16 21:04:32 +02:00

92 lines
1.8 KiB
Bash

source $HOME/Gitea/logger/logger.sh
log_init "/home/alf/log.txt"
log_start
log_info "Starte Lock/Unlock Bashrc"
ende=nein
BASHRC=$HOME/.bashrc
ISTSUDO="nein" # nur für root, sonst "nein"
while [ $ende = "nein" ]; do
echo
echo
echo "1 = LOCK"
echo " "
echo "2 = UNLOCK und Editieren"
echo "22= UNLOCK und Ende"
echo " "
echo "3 = .bashrc neu einlesen"
echo " "
echo "0 = Ende"
echo
read -p "Deine Wahl: 1/2/3/0 " wwahl
if [ $wwahl = 1 ]
then
if [ $ISTSUDO = "ja" ]
then
sudo chattr +i $BASHRC
log_info "Gesichert! (sudo) $?"
else
setfacl -m u::r--,g::r--,o::r-- $BASHRC
log_info "Gesichert! (ACL) $?"
fi
fi
if [ $wwahl = 2 ]
then
if [ $ISTSUDO = "ja" ]
then
sudo chattr -i $BASHRC
log_info "Geöffnet! (sudo) $?"
log_info "öffne Datei..."
nano $BASHRC
log_info "Datei geschlossen $?"
sudo chattr +i $BASHRC
log_info "Gesichert (sudo) $?"
else
setfacl -m u::rwx,g::r--,o::r-- $BASHRC
log_info "Geöffnet! (ACL) $?"
log_info "öffne Datei..."
nano $BASHRC
log_info "Datei geschlossen $?"
setfacl -m u::r--,g::r--,o::r-- $BASHRC
log_info "Gesichert (ACL) $?"
fi
source $BASHRC
echo "Änderungen sind nach dem Neustart der"
echo "Konsole wirksam"
fi
if [ $wwahl = 22 ]
then
if [ $ISTSUDO = "ja" ]
then
sudo chattr -i $BASHRC
log_info "Geöffnet! (sudo) $?"
exit 0
else
setfacl -m u::rwx,g::r--,o::r-- $BASHRC
log_info "Geöffnet! (ACL) $?"
exit 0
fi
fi
if [ $wwahl = "3" ]
then
log_info "Lese neu…"
. $BASHRC
log_info "Err: $?"
fi
if [ $wwahl = "0" ]
then
ende="ja"
fi
done
log_end