summaryrefslogtreecommitdiff
path: root/src/xi.sh
diff options
context:
space:
mode:
authordavidovski <david@davidovski.xyz>2022-04-28 11:49:40 +0100
committerdavidovski <david@davidovski.xyz>2022-04-28 11:49:40 +0100
commit69a4d1ed1f133523fd9d4920b93b272194f5ae80 (patch)
tree53552170084a7d05294bb1352b313848275d4383 /src/xi.sh
parent534ab7fc386021e227e3fb2ea2902af6a75159a1 (diff)
fixed install script and checking for root
Diffstat (limited to 'src/xi.sh')
-rwxr-xr-xsrc/xi.sh18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/xi.sh b/src/xi.sh
index 3a133a9..04dfe2d 100755
--- a/src/xi.sh
+++ b/src/xi.sh
@@ -63,6 +63,12 @@ Available Commands:
shows this message
EOF
}
+checkroot () {
+ [ "$(id -u)" = "0" ] || {
+ printf "${RED}Please run as root!\n"
+ exit 1
+ }
+}
[ -z "${LIBDIR}" ] && LIBDIR=/usr/lib/xipkg
@@ -130,17 +136,15 @@ if [ "$#" = "0" ]; then
show_xipkg_stats
else
# showing stats doesn't require root, so we can only check when we are here
- [ "$(id -u)" = "0" ] || {
- printf "${RED}Please run as root!\n"
- exit 1
- }
# todo check for permissions when we need them and ask them per request
case "$1" in
"sync")
+ checkroot
sync
;;
"install" | "update")
shift
+ checkroot
$DO_SYNC && sync
install $@
;;
@@ -150,15 +154,18 @@ else
;;
"fetch")
shift
+ checkroot
$DO_SYNC && sync
fetch $@
;;
"remove")
shift
+ checkroot
remove $@
;;
"reinstall")
shift
+ checkroot
reinstall $@
;;
"files")
@@ -167,11 +174,13 @@ else
;;
"keyimport")
shift
+ checkroot
set -o noglob
keyimport $@
;;
"clean")
shift
+ checkroot
. ${LIBDIR}/remove.sh
clean $@
;;
@@ -195,6 +204,7 @@ else
;;
"bootstrap")
shift
+ checkroot
. ${LIBDIR}/bootstrap.sh
bootstrap $@
;;