void-bash-installer/main.sh
2021-05-09 21:22:01 +02:00

51 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
dir="$(pwd)"
wrksrc="${dir}/tmp"
functions="${dir}/functions"
vars="${wrksrc}/vars"
dest="${wrksrc}/dest"
files="${dir}/files"
rm -rf "${vars}"
mkdir -p "${wrksrc}" "${vars}" "${dest}"
declare -A cfg=()
declare -A users=()
#set -x
remote="https://alpha.de.repo.voidlinux.org/current"
#remote="https://void.cijber.net/current/"
source "${functions}"/functions
source "${dir}"/config
if mountpoint -q "${dest}"; then
umounter "${dest}"
fi
export run="config"
for i in $(find "${dir}/step1" -mindepth 1 -maxdepth 1 -type f | sort -n ); do
test -f "${i}" && source "${i}"
done
export run="postconfig"
for i in $(find "${dir}/step2" -mindepth 1 -maxdepth 1 -type f | sort -n ); do
test -f "${i}" && source "${i}"
done
mkdir -p "${dest}"/tmp/installer/tmp "${dest}"/etc
cp -rf /etc/resolv.conf "${dest}"/etc
cp -rf "${vars}" "${dest}"/tmp/installer/tmp
#rm -rf "${vars}"
cp -rf "${dir}/step3" "${dest}"/tmp/installer
cp -rf "${dir}/step4" "${dest}"/tmp/installer
cp -rf "${files}" "${dest}"/tmp/installer
cp -rf "${functions}" "${dest}"/tmp/installer
cp -rf ./run_in_chroot.sh "${dest}"/tmp/installer
for i in $(seq 1 "${users[amount]}"); do
pw+=( "${users[pw$i]}" )
done
chroot "${dest}" "/tmp/installer/run_in_chroot.sh" "${cfg[diskpw]}" "${pw[@]}"
umounter "${dest}"