post install script
This commit is contained in:
parent
a21989bf15
commit
b1079497c8
3 changed files with 87 additions and 24 deletions
31
installer.sh
31
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"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue