script fixes
This commit is contained in:
parent
0c841b6689
commit
ecdd982dea
|
@ -15,19 +15,15 @@ for i in $dircontent
|
|||
end
|
||||
|
||||
if fish_is_root_user
|
||||
echo "[ERROR] Running with root permissions is not supported"
|
||||
logprint "EXIT" "red" "running as root is not supported"
|
||||
exit 0
|
||||
else
|
||||
set hash1 "$(cat temp/directorylisthashed.txt)"
|
||||
set hash1 $(string split " " $hash1)
|
||||
set hash1 $hash1[1]
|
||||
set hash2 "$(cat temp/directorylisthashedprevious.txt)"
|
||||
set hash2 $(string split " " $hash2)
|
||||
set hash2 $hash2[1]
|
||||
if [ "$hash1" != "$hash2" ]
|
||||
read -sP "[INPUT] Root password: " rpass
|
||||
if [ "$rpass" = "" ]
|
||||
echo "[ERROR] Failed to get root password"
|
||||
logprint "WARN" "yellow" "empty root password"
|
||||
exit 0
|
||||
end
|
||||
echo "$rpass" | sudo -S echo "[INFO] Obtaining admin permissions"
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
black 30
|
||||
red 31
|
||||
green 32
|
||||
yellow 33
|
||||
blue 34
|
||||
magenta 35
|
||||
cyan 36
|
||||
white 37
|
||||
default 39
|
||||
reset 0
|
|
@ -1,2 +1,13 @@
|
|||
#!/bin/fish
|
||||
|
||||
function logprint
|
||||
if [ $(string length "$argv[1]") != 4 ]
|
||||
logprint "FAIL" "red" "invalid log type length passed to logprint"
|
||||
return 0
|
||||
end
|
||||
set logclass $(echo "$argv[1]" | string upper)
|
||||
set logcolorcode $(string replace "_" $(cat "./scripts/resources/ansicolorsmap.txt"| grep "$argv[2]" | string replace "$argv[2] " "") "\x1b[_m")
|
||||
set logmessage "$argv[3]"
|
||||
|
||||
printf "[$logcolorcode$logclass\x1b[0m] $logmessage\n"
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue