From 69a4d1ed1f133523fd9d4920b93b272194f5ae80 Mon Sep 17 00:00:00 2001 From: davidovski Date: Thu, 28 Apr 2022 11:49:40 +0100 Subject: fixed install script and checking for root --- Makefile | 2 +- scripts/install.sh | 2 +- src/bootstrap.sh | 2 +- src/xi.sh | 18 ++++++++++++++---- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index d021790..62de696 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ install: install-config install -m755 ${SOURCE}/xi.sh ${DESTDIR}${PREFIX}/bin/xi git describe --always > ${DESTDIR}${PREFIX}/lib/xipkg/VERSION -install-config: +install-config: mkdir -p $(DESTDIR)${CONFDIR}/xipkg.d/ cp default.conf $(DESTDIR)${CONFDIR}/xipkg.d/ cp xipkg.conf $(DESTDIR)${CONFDIR}/xipkg.conf diff --git a/scripts/install.sh b/scripts/install.sh index d342281..0db895e 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -5,7 +5,7 @@ additional_packages="sudo neofetch vim networkmanager" default_key="davidovski https://xi.davidovski.xyz/keychain/xi.pub" XIPKG="/usr/bin/xi" -XIFLAGS="-yl" +XIFLAGS="-ylu" TMPDIR=/tmp SYSROOT=$1 diff --git a/src/bootstrap.sh b/src/bootstrap.sh index 55060b3..91d82b6 100644 --- a/src/bootstrap.sh +++ b/src/bootstrap.sh @@ -22,7 +22,7 @@ create_directories () { ln -s usr/lib ${SYSROOT}/lib64 ln -s usr/lib ${SYSROOT}/usr/lib64 - ln -s usr ${SYSROOT}/usr/local + ln -s ../usr ${SYSROOT}/usr/local chmod 0755 ${SYSROOT}/dev chmod 1777 ${SYSROOT}/tmp chmod 0555 ${SYSROOT}/sys 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 $@ ;; -- cgit v1.2.1