require sudo for -r, remove hardcoded password
This commit is contained in:
1 parent
f1933088da
commit
45a713cfc5
1 file changed
+9
-37
@@ -2,8 +2,6 @@
|
||||
|
||||
# GNU GPL v3 2025 K9BFF
|
||||
|
||||
|
||||
# gots 2 make sure
|
||||
su_check() {
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
echo "sysop: needs to be run as sudo..."
|
||||
@@ -11,35 +9,22 @@ su_check() {
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
|
||||
# inverse sudo check because i found a bug last night
|
||||
inv_su_check() {
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
:
|
||||
else
|
||||
echo "sysop: don't run this flag as sudo!"
|
||||
exit 1
|
||||
fi
|
||||
if [[ $EUID -eq 0 ]]; then
|
||||
echo "sysop: don't run this flag as sudo!"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
|
||||
# rebuild
|
||||
if [[ $1 == "-r" ]]; then
|
||||
inv_su_check
|
||||
update-dotfiles
|
||||
sudo nixos-rebuild switch |& nom
|
||||
su_check
|
||||
update-dotfiles
|
||||
nixos-rebuild switch |& nom
|
||||
|
||||
|
||||
# upgrade
|
||||
elif [[ $1 == "-u" ]]; then
|
||||
su_check
|
||||
nixos-rebuild switch --upgrade |& nom
|
||||
|
||||
|
||||
|
||||
# garbage collection
|
||||
elif [[ $1 == "-d" ]]; then
|
||||
su_check
|
||||
read -p "sysop: garbage collection: are you sure? (y/N): " yesno
|
||||
@@ -50,25 +35,15 @@ elif [[ $1 == "-d" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
|
||||
# nix-shell
|
||||
elif [[ $1 == "-p" ]]; then
|
||||
inv_su_check
|
||||
inv_su_check
|
||||
nix-shell -p "$2" |& nom
|
||||
|
||||
|
||||
|
||||
# search
|
||||
elif [[ $1 == "-s" ]]; then
|
||||
inv_su_check
|
||||
inv_su_check
|
||||
nix-search "$2"
|
||||
|
||||
|
||||
|
||||
# help
|
||||
elif [[ $1 == "-h" ]]; then
|
||||
inv_su_check
|
||||
echo "sysop: system operations"
|
||||
echo
|
||||
echo "flag operation"
|
||||
@@ -79,9 +54,6 @@ elif [[ $1 == "-h" ]]; then
|
||||
echo "-s Search"
|
||||
echo "-h Display this help"
|
||||
|
||||
|
||||
|
||||
# bad flag detector
|
||||
else
|
||||
echo "sysop: $1: not a valid flag. Please see sysop -h for more information."
|
||||
exit 1
|
||||
|
||||
Reference in new issue
Block a user