summaryrefslogtreecommitdiff
path: root/src/bootstrap.sh
diff options
context:
space:
mode:
authordavidovski <david@davidovski.xyz>2022-02-20 14:32:34 +0000
committerdavidovski <david@davidovski.xyz>2022-02-20 14:32:34 +0000
commit5e64673025351660b27ad61e215ef38a8f033c85 (patch)
tree87f8f11c38a447835e546fc8c579308e88d4ebee /src/bootstrap.sh
parent8f02115e50573be0a5c6653f2a4a2bb6d7459911 (diff)
added bootstrapping
Diffstat (limited to 'src/bootstrap.sh')
-rw-r--r--src/bootstrap.sh59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/bootstrap.sh b/src/bootstrap.sh
new file mode 100644
index 0000000..846e8c3
--- /dev/null
+++ b/src/bootstrap.sh
@@ -0,0 +1,59 @@
+#!/bin/sh
+
+DEFAULT_KEYS="davidovski https://xi.davidovski.xyz/keychain/xi.pub"
+
+create_directories () {
+ mkdir -p ${SYSROOT}
+ mkdir -p ${SYSROOT}/dev
+ mkdir -p ${SYSROOT}/tmp
+ mkdir -p ${SYSROOT}/sys
+ mkdir -p ${SYSROOT}/run
+ mkdir -p ${SYSROOT}/proc
+ mkdir -p ${SYSROOT}/usr
+ mkdir -p ${SYSROOT}/root
+ mkdir -p ${SYSROOT}/usr/bin
+ mkdir -p ${SYSROOT}/usr/lib
+
+ ln -s usr/bin ${SYSROOT}/bin
+ ln -s usr/bin ${SYSROOT}/sbin
+ ln -s bin ${SYSROOT}/usr/sbin
+
+ ln -s usr/lib ${SYSROOT}/lib
+ ln -s usr/lib ${SYSROOT}/lib64
+ ln -s usr/lib ${SYSROOT}/usr/lib64
+
+ ln -s usr ${SYSROOT}/usr/local
+}
+
+import_keys () {
+ # import all keys
+ set -o noglob
+ if [ -d ${KEYCHAIN_DIR} ] && [ "$(ls ${KEYCHAIN_DIR} | wc -w)" != "0" ]; then
+ keyimport *
+ else
+ keyimport $DEFAULT_KEYS
+ fi
+}
+
+bootstrap () {
+ if [ "${SYSROOT}" = "/" ]; then
+ printf "${RED}Error! Cannot bootstrap on existing system! Use ${LIGHT_RED}--root${RED} to specify new root filesystem\n"
+ return 1
+ fi
+
+ if [ -e ${SYSROOT} ] && [ "$(ls -1 ${SYSROOT})" != "0" ]; then
+ if prompt_question "${WHITE}System already exists on ${SYSROOT}, clear?"; then
+ rm -rf ${SYSROOT}/*
+ fi
+ fi
+
+ printf "${BLUE}Creating directories..."
+ create_directories
+ printf "${GREEN}${CHECKMARK}\n"
+
+ sync
+
+ install base linux xipkg $@
+
+ import_keys
+}