From b1079497c896ba9438ad5e4baabb34a969ab40e5 Mon Sep 17 00:00:00 2001 From: amolinae06 Date: Sun, 18 May 2025 18:35:09 -0600 Subject: [PATCH] post install script --- devware.csv | 32 ++++++++++++++++---------------- installer.sh | 31 +++++++++++++++++++++++-------- postinstall.sh | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+), 24 deletions(-) create mode 100644 postinstall.sh diff --git a/devware.csv b/devware.csv index 3d62c1c..38ff5cb 100644 --- a/devware.csv +++ b/devware.csv @@ -1,16 +1,16 @@ -NAME,DESCRIPTION,GIT,GIT URL -build-base,"Meta package for build base",N, -tcc,"Tiny C Compiler",N, -tcc-libs,"Tiny C Compiler (libraries)",N, -tcc-libs-static,"Tiny C Compiler (static library)",N, -clang20,"C language family front-end for LLVM",N, -libinput,"Library for handling input devices",N, -libinput-dev,"Library for handling input devices (development files)",N, -wayland,"A computer display server protocol",N, -wayland-dev,"A computer display server protocol (development files)",N, -wlroots,"Modular Wayland compositor library",N, -wlroots-dev,"Modular Wayland compositor library (development files)",N, -libxkbcommon,"keyboard handling library",N, -libxkbcommon-dev,"keyboard handling library (development files)",N, -wayland-protocols,"Protocols and protocol extensions complementing the Wayland core protocol",N, -pkgconf,"development framework configuration tools",N, +NAME,DESCRIPTION,GIT, +build-base,"Meta package for build base",D, +tcc,"Tiny C Compiler",D, +tcc-libs,"Tiny C Compiler (libraries)",D, +tcc-libs-static,"Tiny C Compiler (static library)",D, +clang20,"C language family front-end for LLVM",D, +libinput,"Library for handling input devices",D, +libinput-dev,"Library for handling input devices (development files)",D, +wayland,"A computer display server protocol",D, +wayland-dev,"A computer display server protocol (development files)",D, +wlroots,"Modular Wayland compositor library",D, +wlroots-dev,"Modular Wayland compositor library (development files)",D, +libxkbcommon,"keyboard handling library",D, +libxkbcommon-dev,"keyboard handling library (development files)",D, +wayland-protocols,"Protocols and protocol extensions complementing the Wayland core protocol",D, +pkgconf,"development framework configuration tools",D, diff --git a/installer.sh b/installer.sh index 1627642..fff6e6e 100644 --- a/installer.sh +++ b/installer.sh @@ -1,8 +1,8 @@ #!/bin/sh dotfiles="https://git.amolinae.com/amolinae06/dotfiles.git" -software="software.csv" -devsoftware="devware.csv" +software="https://git.amolinae.com/amolinae06/installer/raw/branch/main/software.csv" +postinstall="https://git.amolinae.com/amolinae06/installer/raw/branch/main/postinstall.sh" apk_install(){ echo "installing $1"; apk add "$1" >/dev/null 2>&1 @@ -18,13 +18,17 @@ deploy_dotfiles(){ } read_software(){ - tail -n +2 "$software" | sed -E ':a; s/("[^"]*),([^"]*")/\1\2/; ta' | while IFS=',' read -r NAME DESCRIPTION GIT GIT_URL; do + ([ -f "$1" ] && cp "$1" /tmp/temp.csv) || wget -qO- "$1" > /tmp/temp.csv + + tail -n +2 "/tmp/temp.csv" | sed -E ':a; s/("[^"]*),([^"]*")/\1\2/; ta' | while IFS=',' read -r NAME DESCRIPTION GIT GIT_URL; do case "$GIT" in "N") apk_install $NAME ;; "Y") git_install "$GIT_URL" ;; *) echo "ERROR: failed to determine $NAME."; exit 1 ;; esac done + + rm "/tmp/temp.csv" printf "Successfully installed all software!\n" } @@ -49,6 +53,9 @@ EOF setup_shell(){ sed -i "/^$user:/s#:[^:]*\$#:/bin/zsh#" /etc/passwd + mkdir -p "/home/$user/.cache/zsh" + touch "/home/$user/.cache/zsh/history" + chown -R "$user":"$user" "/home/$user/.cache/" echo "changed "$user"'s shell to zsh" } @@ -63,21 +70,28 @@ setup_home(){ } setup_chroot(){ - printf "Setting up chroot" + printf "Setting up chroot\n" apk_install curl cd "/home/$user/Documents/Miscellaneous" mkdir alpchroot curl -LO https://dl-cdn.alpinelinux.org/alpine/v3.20/main/x86_64/apk-tools-static-2.14.4-r1.apk tar -xzf apk-tools-static-*.apk - ./sbin/apk.static -X https://dl-cdn.alpinelinux.org/alpine/v3.20/main -U --allow-untrusted -p ${chroot_dir} --initdb add alpine-base + ./sbin/apk.static -X https://dl-cdn.alpinelinux.org/alpine/v3.20/main -U --allow-untrusted -p alpchroot/ --initdb add alpine-base mount -o bind /dev alpchroot/dev mount -t proc none alpchroot/proc mount -o bind /sys alpchroot/sys cp -L /etc/resolv.conf alpchroot/etc/ - chown -R "$user":"$user" alpchroot/ + chown -R "$user":"$user" alpchroot/ >/dev/null 2>&1 mkdir -p alpchroot/etc/apk - echo "https://dl-cdn.alpinelinux.org/alpine/latest-stable/main" > alpchroot/etc/apk/repositories + cp /etc/apk/repositories alpchroot/etc/apk/repositories apk del curl + printf "Finished setting up chroot!\n" +} + +post_install(){ + printf "Postinstall\n" + ([ -f "$postinstall" ] && cp "$postinstall" /tmp/postinstall.sh) || wget -qO- "$1" > /tmp/postinstall.sh + su - "$user" -c "zsh -lc 'sh /tmp/postinstall.sh \"$@\" '" } check_root(){ @@ -95,10 +109,11 @@ check_root echo "Welcome to the installer" apk_install git get_user -read_software +read_software "$software" setup_home deploy_dotfiles setup_greetd setup_shell setup_bluetooth setup_chroot +post_install "$user" diff --git a/postinstall.sh b/postinstall.sh new file mode 100644 index 0000000..1a848fc --- /dev/null +++ b/postinstall.sh @@ -0,0 +1,48 @@ +#!/bin/sh + +software="https://git.amolinae.com/amolinae06/installer/raw/branch/main/devware.csv" + +apk_install(){ + echo "installing $1"; bwroot apk add "$1" >/dev/null 2>&1 +} + +read_software(){ + ([ -f "$1" ] && cp "$1" /tmp/temp.csv) || wget -qO- "$1" > /tmp/temp.csv + + tail -n +2 "/tmp/temp.csv" | sed -E ':a; s/("[^"]*),([^"]*")/\1\2/; ta' | while IFS=',' read -r NAME DESCRIPTION GIT GIT_URL; do + case "$GIT" in + "D") apk_install $NAME ;; + *) echo "ERROR: failed to determine $NAME."; exit 1 ;; + esac + done + + rm "/tmp/temp.csv" + printf "Successfully installed all software!\n" +} + +make_dwl() { + cd $HOME/.local/src/dwl/ + bwroot make install +} + +make_slstatus() { + cd $HOME/.local/src/slstatus/ + bwroot make install +} + +make_ctpv() { + cd $HOME/.local/src/hellwal/ + bwroot make install +} + +make_hellwal() { + cd $HOME/.local/src/hellwal/ + bwroot make install +} + +cd "/home/$@/" +read_software $software +make_dwl +make_slstatus +make_ctpv +make_hellwal