first commit

This commit is contained in:
teldra 2021-03-11 14:04:04 +01:00
commit a45a1656cb
39 changed files with 1065 additions and 0 deletions

228
functions/functions Normal file
View File

@ -0,0 +1,228 @@
wronginput() {
printf "Wrong input: %s\n" "${1}"
printf "this is valid: %s\n" "${2}"
}
input() {
output=""
echo "${1}"
read -r -p "[${2}]: " output
test -z "${output}" && output="${2}"
return 0
}
#multiplechoice "networksystem" "dhcpcd" "networkmanager" "iwd" "none"
multiplechoice() {
output=""
local done=""
local input=("${@}")
for i in $(seq 1 "$(( ${#input[@]} - 1 ))"); do
if [[ "${i}" == "1" ]]; then
choices="${input[$i]}"
else
choices="${choices}|${input[$i]}"
fi
done
while input "[${choices}]: " "${input[1]}"; do
for i in $(seq 1 "$(( ${#input[@]} - 1 ))"); do
if [[ "${output}" == "${input[$i]}" ]] || [[ "${output}" == "${input[$i]:0:2}" ]]; then
setconf add "${1}" "${input[$i]}"
done=1
fi
done
if [[ -z "${done}" ]]; then
echo wronginput "${output}"
echo use these: "${input[@]}"
else
break
fi
done
}
#yesno question y
yesno() {
local input=""
local retval=""
local default=""
local q=""
case "${2}" in
Y|y) q="${1} [Y|n]:"; default=y;;
N|n) q="${1} [y|N]:"; default=n;;
esac
while read -r -p "${q} " input; do
test -z "${input}" && input="${default}"
case "${input}" in
y*|Y*|*es*|*ES*|*Es*|*eS*|1)
retval=1
break
;;
n*|N*|0)
retval=""
break
;;
*) wronginput "${input}" "${choices[*]}"
;;
esac
done
if [[ -z "${retval}" ]]; then
return 1
else
return 0
fi
}
input_pw() {
output=""
local pw1=1
local pw2=2
until [[ "${pw1}" == "${pw2}" ]]; do
read -r -s -p "${1}: " pw1 && echo
read -r -s -p "${1} verify: " pw2 && echo
test -z "${pw1}" && pw1=oem
test -z "${pw2}" && pw2=oem
done
echo password set to "\"oem\""
output="${pw1}"
}
#setconf add lang de_DE
#setconf rm lang
setconf() {
case "${1}" in
add)
cfg+=( ["${2}"]="${3}" )
if grep -q -w "${2}" "${var}"; then
sed -i "/${2}/d" "${var}"
fi
[[ "${4}" == "nonvolatile" ]] && echo "cfg+=( [${2}]=\"${3}\" )" >> "${var}" ;;
rm)
cfg+=( [${2}]="" )
sed -i "/${2}/d" "${var}" ;;
esac
}
addpkg() {
local input=( ${@} )
for i in $(seq 0 "$(( ${#input[@]} - 1 ))"); do
pkg+=( "${input[$i]}" )
#echo "pkg+=( \"${input[$i]}\" )" >> "${vars}/pkg"
done
}
ignorepkg() {
local input=( ${@} )
for i in $(seq 0 "$(( ${#input[@]} - 1 ))"); do
ignorepkg+=( "${input[$i]}" )
#echo "pkg+=( \"${input[$i]}\" )" >> "${vars}/pkg"
done
}
servicesenable() {
local input=( ${@} )
for i in $(seq 0 "$(( ${#input[@]} - 1 ))"); do
services_enable+=( "${input[$i]}" )
done
}
servicesdisable() {
local input=( ${@} )
for i in $(seq 0 "$(( ${#input[@]} - 1 ))"); do
services_disable+=( "${input[$i]}" )
done
}
ignorepkg() {
local input=( ${@} )
for i in $(seq 0 "$(( ${#input[@]} - 1 ))"); do
ignorepkg+=( "${input[$i]}" )
done
}
check() {
if [[ $1 == "alnum" ]]; then
if [[ "${2}" =~ ^[[:alnum:]]+$ ]] || [[ "${2}" =~ ^[0-9A-Za-z._]+$ ]]; then
return 0
else
echo "only alphanumerics and ._"
return 1
fi
elif [[ $1 == "num" ]]; then
if [[ "${2}" =~ ^[0-9]+$ ]]; then
return 0
else
echo "only numbers ${2}"
return 1
fi
fi
}
#useradd valuename index value
useradder() {
users+=( ["${1}${2}"]="${3}" )
#echo "users+=( [${1}${2}]=${3} )"
echo "users+=( [${1}${2}]=\"${3}\" )" >> "${var}"
}
module() {
case $1 in
start)
#if [[ ! "${4}" == "dontcheck" ]]; then
# test -f "${steps}/${2}-${run}" && return 1
#fi
modulename="${2}"
var="${vars}/${modulename}"
desc="${3}"
echo "${3}.."
#[[ "${run}" == "pre" ]] && rm -rf "${var}" && touch "${var}"
touch "${var}"
#return 0
;;
end)
#touch "${step}"
modulename=""
var=""
step=""
donttouch=""
setstep=""
;;
esac
}
umounter() {
umount -R "${1}"
vgchange -an
for i in $(find /dev/mapper -name "voidluks*" -printf "%P\n"); do
cryptsetup close "${i}"
done
}
inst() {
echo "install from ${remote}" "${@}"
xbps-install -Sy -R "${remote}" -r "${dest}" "${@}" || exit
}
remove() {
xbps-remove -Ry -r "${dest}" "${ignorepkg[@]}" "${@}" || exit
}
#if findinarray "${i}" "${array[@]}"; then echo found; fi
findinarray() {
local input=()
local index=1
for i in "${@}"; do
if [[ ! "${index}" == "1" ]]; then
input+=( "${i}" )
fi
index=$(( index + 1 ))
done
for i in "${input[@]}"; do
if [[ "${i}" == "${1}" ]]; then
return 0
fi
done
return 1
}

41
main.sh Executable file
View File

@ -0,0 +1,41 @@
#!/bin/bash
dir="$(pwd)"
wrksrc="${dir}/tmp"
functions="${dir}/functions"
modules="${dir}/modules"
config_mods="${modules}/config"
install_mods="${modules}/install"
chroot_mods="${modules}/chroot"
vars="${wrksrc}/vars"
dest="${wrksrc}/dest"
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
umounter "${dest}"
export run="pre"
for i in $(find "${modules}" -mindepth 1 -maxdepth 1 -type d | sort -n ); do
test -f "${i}"/pre && source "${i}"/pre
done
export run="install"
for i in $(find "${modules}" -mindepth 1 -maxdepth 1 -type d | sort -n ); do
test -f "${i}"/install && source "${i}"/install
done
mkdir -p "${dest}"/tmp/installer/tmp
cp -rf "${vars}" "${dest}"/tmp/installer/tmp
cp -rf "${modules}" "${dest}"/tmp/installer
cp -rf "${functions}" "${dest}"/tmp/installer
cp -rf ./run_in_chroot.sh "${dest}"/tmp/installer
chroot "${dest}" "/tmp/installer/run_in_chroot.sh"
umounter "${dest}"

113
modules/10-disk/install Normal file
View File

@ -0,0 +1,113 @@
module start "disk" "Partition disk"
source "${var}"
#umounter "${dest}" || exit
if [[ ! "${cfg[fde_key_store]}" == "none" ]]; then
addpkg cryptsetup
fi
diskid="${cfg[diskid]//-/_}"
if [[ -n "${cfg[wipe]}" ]]; then
echo "Formatting disk"
echo "o
w
q" | fdisk "${cfg[diskname]}" 2>1 > /dev/null
fi
if [[ "${cfg[fde_key_store]}" == "once" ]]; then
echo "create bootpartition"
target_boot="${cfg[diskname]}1"
echo "n
p
1
+${cfg[bootsize]}G
a
w
q" | fdisk "${cfg[diskname]}" 2>1 > /dev/null
if [[ "${cfg[rootfssize]}" == "rest" ]]; then
target_partition_tmp="${cfg[diskname]}2"
echo "create rootfs"
echo "n
p
2
w
q" | fdisk "${cfg[diskname]}" 2>1 > /dev/null
elif [[ ! "${cfg[rootfssize]}" == "rest" ]]; then
target_partition_tmp="${cfg[diskname]}2"
echo "create rootfs with a specific size"
echo "n
p
2
+${rootfssize}G
w
q" | fdisk "${cfg[diskname]}" 2>1 > /dev/null
fi
else
if [[ "${cfg[rootfssize]}" == "rest" ]]; then
target_partition_tmp="${cfg[diskname]}1"
echo "create rootfs without boot"
echo "n
p
1
a
w
q" | fdisk "${cfg[diskname]}" 2>1 > /dev/null
elif [[ ! "${cfg[rootfssize]}" == "rest" ]]; then
target_partition_tmp="${cfg[diskname]}1"
echo "create rootfs with a specific size without boot"
echo "n
p
1
 
+${rootfssize}G
a
w
q" | fdisk "${cfg[diskname]}" 2>1 > /dev/null
fi
fi
target_partition="${target_partition_tmp}"
if [[ ! "${fde_key_store}" == "none" ]]; then
echo -n "${cfg[diskpw]}" | cryptsetup luksFormat --type luks1 "${target_partition}" -d -
echo -n "${cfg[diskpw]}" | cryptsetup luksOpen "${target_partition}" "voidluks-${diskid}" -d -
target_partition="/dev/mapper/voidluks-${diskid}"
fi
vgcreate -q -f "voidvg.${diskid}" "${target_partition}" || exit 1
lvcreate -q -y --name swap -L "${cfg[swapsize]}"G "voidvg.${diskid}"
lvcreate -q -y --name root -l 100%FREE "voidvg.${diskid}"
mkfs.btrfs -q -f "/dev/mapper/voidvg.${diskid}-root"
mkswap "/dev/mapper/voidvg.${diskid}-swap"
mount "/dev/mapper/voidvg.${diskid}-root" "${dest}"
btrfs subvol create "${dest}/void-rootfs"
btrfs subvol create "${dest}/home"
umount "${dest}"
mount "/dev/mapper/voidvg.${diskid}-root" "${dest}" -o subvol=void-rootfs
for i in boot home dev proc sys tmp etc var/lib/backup var/db; do mkdir -p "${dest}/${i}"; done
mount "/dev/mapper/voidvg.${diskid}-root" "${dest}"/home -o subvol=home
if [[ "${cfg[fde_key_store]}" == "once" ]]; then
mkfs.btrfs -q -f "${target_boot}"
mount "${target_boot}" "${dest}/boot"
fi
for dir in dev proc sys run; do mkdir -p "${dest}"/$dir ; mount --rbind /$dir "${dest}"/$dir ; mount --make-rslave "${dest}"/$dir ; done
setconf add rootuuid "$(blkid -o value -s UUID ${target_partition})"
setconf add partuuid "$(blkid -o value -s UUID ${cfg[diskname]}${cfg[target_part]})"
[[ "${cfg[fde_key_store]}" == "once" ]] && setconf "add" "bootuuid" "$(blkid -o value -s UUID ${target_boot})"
setconf add swapuuid "$(blkid -o value -s UUID /dev/mapper/voidvg.${diskid}-swap)"
mount -t tmpfs -o size=512m tmpfs "${dest}"/tmp
module end

163
modules/10-disk/pre Normal file
View File

@ -0,0 +1,163 @@
module start "disk" "Partition disk"
# find all disks
declare -A disk_tmp=()
declare -A disk=()
index=0
for i in $(find /dev/disk/by-id/ -type l -printf "%P\n"|grep -v "part" |tac); do
name="$(readlink -f /dev/disk/by-id/"${i}")"
if [[ "${name}" =~ *"^[0-9]+$"* ]]; then
continue
fi
if [[ "${name}" == *"dm"* ]]; then
continue
fi
if [[ "${name}" == *"/dev/sr"* ]]; then
continue
fi
index=$(( index + 1 ))
size="$(fdisk -l "${name}" | head -n1 | awk '{print $3}')"
size=$(awk "BEGIN { printf(\"%.0f\n\", ${size}); }")
size="$(( size - 1 ))"
disk_tmp+=( [${index}.id]="${i}" [${index}.name]="${name}" [${index}.size]="${size}" )
done
disk_tmp+=( [count]="${index}" )
# show devices
echo "Devices:"
for i in $(seq 1 "${disk_tmp[count]}"); do
echo "${disk_tmp[${i}.id]}" "${disk_tmp[${i}.name]}" "${disk_tmp[${i}.size]}"
done
# if set device on commandline, use this as default
if [[ -z "${extern_device}" ]]; then
device="${disk_tmp[1.id]}"
else
device="${extern_device}"
fi
# choose device
found=""
while input "Which Device?" "${device}"; do
test -z "${output}" && output="${default}"
for i in $(seq 1 "${disk_tmp[count]}"); do
if [[ "${disk_tmp[${i}.id]}" == "${output}" ]] || [[ "${disk_tmp[${i}.name]}" == "${output}" ]]; then
found=1
disk+=( [id]="${disk_tmp[${i}.id]}" )
disk+=( [name]="${disk_tmp[${i}.name]}" )
disk+=( [size]="${disk_tmp[${i}.size]}" )
break
fi
done
[[ "${found}" == "1" ]] && break
echo "${output} not found"
done
# if there are partitions, show them and warn
# user choose between exit und wipe
partitions=""
index=""
for i in "$(lsblk -n -l "${disk[name]}" | tail -n +2 | grep part)"; do
echo "${i}"
index=$(( index + 1 ))
done
if [[ "${#partitions[@]}" -gt 0 ]]; then
echo "there are partitions"
while input "wipe or quit?" "wipe"; do
case "${output}" in
w*|*p*|*W*|*P*)
setconf add wipe "1"
break
;;
q*|*u*|*t*|*Q*|*U*|*T*)
echo mount / under /mnt
echo mount /boot under /mnt/boot
echo mount /home under /mnt/home
echo create swap
echo start again with -m
exit
;;
*) echo "please enter wipe or quit"
;;
esac
done
fi
echo "######"
echo "With Full Disk Encryption the whole disk will be encrypted,"
echo "including /boot. Unlike Ubuntu."
echo "If you choose FDE, you have to enter the password for the"
echo "disc twice, unless you save the key on an usbstick or"
echo "include it into initramfs."
echo "If its included, remember: grub only knows us keylayout: no umlauts"
echo "If you choose to enter once, kernel (/boot) is unencrypted on disk."
echo "You can turn off encryption."
echo "######"
multiplechoice "fde_key_store" "initramfs" "usb" "once" "twice" "notencrypted"
if [[ ! "${cfg[fde_key_store]}" == "none" ]]; then
input_pw "Disk Password"
setconf "add" "diskpw" "${output}"
fi
if check yesno "Do you want to hibernate?" "y"; then
hibernate=1
setconf "add" "hibernate" "1"
fi
ramsize="$(($(getconf _PHYS_PAGES) * $(getconf PAGE_SIZE) / (1024 * 1024)))"
ramsize="$(awk "BEGIN { printf(\"%.0f\n\", ${ramsize}/1024); }")"
if [[ "${ramsize}" -le "2" ]]; then
test -z "${hibernate}" && swapsize="$(( ramsize * 2 ))"
test -z "${hibernate}" || swapsize="$(( ramsize * 3 ))"
elif [[ "${ramsize}" -gt "2" ]] && [[ "${ramsize}" -le "7" ]]; then
test -z "${hibernate}" && swapsize="${ramsize}"
test -z "${hibernate}" || swapsize="$(( ramsize * 2 ))"
elif [[ "${ramsize}" -gt "8" ]] && [[ "${ramsize}" -le "15" ]]; then
test -z "${hibernate}" && swapsize="${ramsize}"
test -z "${hibernate}" || swapsize="$(awk "BEGIN { printf(\"%.0f\n\", ${ramsize}*1.5); }")"
elif [[ "${ramsize}" -gt "15" ]]; then
test -z "${hibernate}" && swapsize="4"
test -z "${hibernate}" || read -p "hibernate not recommended, turning off" empty && hibernate=""
fi
if [[ "${cfg[fde_key_store]}" == "once" ]]; then
echo Configure /boot
while input "Size in G?" "4"; do
if check num "${output}"; then
bootsize="${output}"
setconf "add" "bootsize" "${output}"
setconf "add" "target_part" "2"
break
fi
done
else
setconf "add" "target_part" "1"
fi
echo Configure rootfssize
while input "Size in G? [$(( disk[size] - swapsize - bootsize ))|rest]" "rest"; do
test -z "${output}" && output="${default}"
case "${output}" in
rest) rootfssize="${output}" && break ;;
esac
if [[ "${output}" =~ ^[0-9]+$ ]] && [[ "${output}" -le "$(( disk[size] - cfg[swapsize] - cfg[bootsize] ))" ]]; then
rootfssize="${output}"
break
fi
done
setconf "add" "fde_key_store" "${cfg[fde_key_store]}"
setconf "add" "fde_keystore" "${cfg[fde_key_store]}"
setconf "add" "FDE_KEY_STORE" "${cfg[fde_key_store]}"
setconf "add" "diskid" "${disk[id]}"
setconf "add" "swapsize" "${swapsize}"
setconf "add" "rootfssize" "${rootfssize}"
setconf "add" "wipe" "${cfg[wipe]}"
setconf "add" "diskname" "${disk[name]}" "nonvolatile"
module end

View File

@ -0,0 +1,23 @@
module start "installation" "Installation" "dontcheck"
echo ""
echo "recent fingerprint: 60:ae:0c:d6:f0:95:17:80:bc:93:46:7a:89:af:a3:2d"
echo ""
if [[ "${#ignorepkg[@]}" -gt 0 ]]; then
mkdir -p "${dest}"/etc/xbps.d/
touch "${dest}"/etc/xbps.d/10-ignore-pkg.conf
for ig in "${ignorepkg[@]}"; do
if ! grep -q "${ig}" "${dest}"/etc/xbps.d/10-ignore-pkg.conf; then
echo "ignorepkg=${ig}" >> "${dest}"/etc/xbps.d/10-ignore-pkg.conf
fi
done
fi
if [[ "${#pkg[@]}" -gt 0 ]]; then
inst "${pkg[@]}"
else
echo nothing to do
fi
module end

View File

@ -0,0 +1,11 @@
module start "installation" "Reconfigure Installation" "dontcheck"
ver="$(xbps-query -S linux|grep pkgver|awk '{print $2}')"
ver="${ver//-}"
ver="${ver%_*}"
#xbps-reconfigure -f "${ver}"
#xbps-reconfigure -f glibc-locales
xbps-reconfigure -af
module end

20
modules/30-users/post Normal file
View File

@ -0,0 +1,20 @@
module "start" "users" "Configuring Users"
source "${var}"
for i in $(seq 1 "${users[amount]}"); do
if ! cut -d: -f1 /etc/passwd | grep -q -w "${users[name$i]}"; then
useradd -G audio,video,floppy,cdrom,optical,input,users "${users[desc$i]}" -m -s "${users[shell$i]}" -U "${users[name$i]}"
if [[ ! -z "${users[sudo$i]}" ]]; then
usermod -a -G socklog,wheel,lpadmin "${i}"
fi
echo password for "${users[name$i]}"
echo -e "${users[pw$i]}\n${users[pw$i]}" | passwd "${users[name$i]}"
else
echo bereits in /etc/passwd vorhanden: "${users[name$i]}"
echo ueberspinge..
#fortfahren?
fi
done
module end

85
modules/30-users/pre Normal file
View File

@ -0,0 +1,85 @@
module "start" "users" "Configuring Users"
repeat=""
index="0"
amount_of_usernames="0"
counter="0"
while echo $((index++)) > /dev/null; do
if [[ "${repeat}" == "1" ]] || [[ "${standalone}" == "1" ]]; then
while input "how many users?" "1"; do
if check num "${output}"; then
amount_of_usernames="${output}"
break
fi
done
elif [[ "${#additional_user[@]}" -gt 0 ]]; then
amount_of_usernames="${#additional_user[@]}"
else
amount_of_usernames=1
fi
for i in $(seq 1 "${amount_of_usernames}"); do
if [[ ! -z "${additional_user[$i]}" ]]; then
echo "additional_user: ${additional_user[$i]}"
output="${additional_user[$i]}"
additional_user+=( [$i]="" )
else
while input "Username:" "voiduser"; do
#if grep -q -w "${output}" /etc/passwd; then
# useradder "name" "${counter}" "${output}"
# echo user exists in the system
# continue
#fi
found=""
for n in ${usernames[@]}; do
if [[ "${n}" == "${output}" ]]; then
echo user was configured before
found=1
fi
done
test -z "${found}" || continue
if check alnum "${output}"; then
counter=$(( counter + 1 ))
useradder "name" "${counter}" "${output}"
usernames+=( "${output}" )
break
fi
done
fi
input "full name (optional)" "${output}"
useradder "desc" "${i}" "-c ${output}"
if [[ "${repeat}" == "1" ]] || [[ "${standalone}" == "1" ]]; then
if yesno "sudo?" n; then
useradder "sudo" "${counter}" ",wheel,socklog"
else
useradder "sudo" "${counter}" ""
fi
elif [[ ! "${repeat}" == "1" ]]; then
useradder "sudo" "${counter}" ",wheel,socklog"
fi
while input "shell?" "/usr/bin/bash"; do
if test -x "$(command -v "${output}")"; then
useradder "shell" "${counter}" "$(command -v "${output}")"
# hier mal ne sicherheitsabfrage ob user das wirklich will
break
fi
echo not found or executable: "${shell_intern}"
done
done
input_pw "User ${users[name${counter}]} password"
useradder "pw" "${counter}" "${output}"
if ! yesno "More users?" "n"; then
break
fi
#set -x
repeat=1
additional_user=()
done
useradder "am" "ount" "${counter}"
module end

View File

@ -0,0 +1,64 @@
module start "basesystem" "Install Basesystem"
source "${var}"
source "${vars}/disk"
chown root:root /
chmod 755 /
mkdir -p "${dest}"/etc/xbps.d/
{ echo "#ignorepkg=linux-firmware-amd";
echo "#ignorepkg=linux-firmware-intel";
echo "#ignorepkg=linux-firmware-nvidia";
echo "#ignorepkg=linux-firmware-broadcom";
echo "#ignorepkg=wifi-firmware"; } > "${dest}"/etc/xbps.d/10-ignore-firmware.conf
{ echo "en_DK.UTF-8 UTF-8";
echo "en_US.UTF-8 UTF-8"; } > "${dest}"/etc/default/libc-locales
echo "LANG=en_US.UTF-8" > "${dest}"/etc/locale.conf
if [[ ! -z "${cfg[lang]}" ]]; then
echo "KEYMAP=${cfg[lang_console]}" > "${dest}"/etc/vconsole.conf
echo "${cfg[lang]}.UTF-8 UTF-8" >> "${dest}"/etc/default/libc-locales
echo "LANG=${cfg[lang]}.UTF-8" > "${dest}"/etc/locale-user.conf
cp -a "${dest}"/etc/profile.d/locale.sh "${dest}"/etc/profile.d/locale-user.sh
sed -i 's/locale.conf/locale-user.conf/' "${dest}"/etc/profile.d/locale-user.sh
fi
{ echo "tmpfs /tmp tmpfs defaults,nosuid,nodev 0 0";
echo "/dev/mapper/voidvg.${diskid}-root / btrfs defaults,subvol=void-rootfs 0 0";
echo "/dev/mapper/voidvg.${diskid}-root /home btrfs defaults,subvol=home 0 0";
echo "/dev/mapper/voidvg.${diskid}-swap swap swap defaults 0 0"; } > "${dest}"/etc/fstab
[[ "${cfg[fde_key_store]}" == "once" ]] && echo "UUID=${cfg[bootuuid]} /boot btrfs defaults 0 0" >> "${dest}"/etc/fstab
mkdir -p "${dest}"/etc/sudoers.d
{ echo 'Defaults timestamp_timeout=15';
echo 'Defaults !tty_tickets';
echo 'Defaults umask = 022';
echo 'Defaults passprompt="[sudo] Password: "';
echo '%wheel ALL=(ALL) ALL';
echo 'Defaults editor = /usr/bin/nvim';
echo 'Defaults env_keep += "EDITOR"'; } > "${dest}"/etc/sudoers.d/10-common
mkdir -p "${dest}"/etc/udev/rules.d/
echo 'ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{UDISKS_FILESYSTEM_SHARED}="1"' > "${dest}"/etc/udev/rules.d/mount-media.rules
echo 'ACTION=="add|change", KERNEL=="sd[a-z]|mmcblk[0-9]*", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="mq-deadline"' > "${dest}"/etc/udev/rules.d/60-ioschedulers.rules
mkdir -p "${dest}"/etc/bash/bashrc.d/
{ echo 'alias xu="sudo xi -Su"';
echo 'alias xr="sudo xbps-install -R"';
echo 'alias xs="xbps-query -Rs"';
echo 'alias xk="sudo vkpurge rm all"';
echo 'echo "xu = sudo xbps-install -Su zum updaten"';
echo 'echo "xi = sudo xbps-install -S zum installieren"';
echo 'echo "xr = sudo xbps-install -R zum deinstallieren"';
echo 'echo "xs = xbps-query -Rs zum suchen"';
echo 'echo "xk = sudo vkpurge rm all zum kernel entfernen"'; } > "${dest}"/etc/bash/bashrc.d/xbps-aliase.sh
echo "${cfg[hostname]}" > "${dest}/etc/hostname"
ln -sf "/usr/share/zoneinfo/${cfg[timezone]}" "${dest}/etc/localtime"
sed -i "s/#HOSTNAME=\"void-live\"/HOSTNAME=${cfg[hostname]}/g" "${dest}/etc/rc.conf"
sed -i "s/Europe\/Madrid/${cfg[timezone]//\//\\/}/" "${dest}/etc/rc.conf"
sed -i "/HARDWARECLOCK/s/^#//g" "${dest}/etc/rc.conf"
sed -i "/FONT=/s/^#//g" "${dest}/etc/rc.conf"
module end

View File

@ -0,0 +1,3 @@
setconf add "lang" "de_DE"
setconf add "lang_console" "de-latin1-nodeadkeys"
setconf add "timezone" "Europe/Berlin"

View File

@ -0,0 +1,3 @@
setconf add "lang" "en_US"
setconf add "lang_console" "de-latin1-nodeadkeys"
setconf add "timezone" "Europe/Berlin"

36
modules/40-basesystem/pre Normal file
View File

@ -0,0 +1,36 @@
module start "basesystem" "Configure Basesystem"
while input "hostname?" "void"; do
if check alnum "${output}"; then
setconf add hostname "${output}"
break
fi
done
if grep -q -v "^#" /etc/default/libc-locales; then
grep -v "^#" /etc/default/libc-locales | awk '{print $1}' | sed 's/.UTF-8//'
echo maybe one of these
fi
while input "language search [en_US|de_DE|..]:" "en_US"; do
lang_tmp="${output}"
break
#if sed 's/#//' /etc/default/libc-locales | grep "UTF-8" | sed 's/.UTF-8//' | awk '{print $1}' "${output}"; then
# lang_tmp="${output}"
# break
#elif ! grep -i -q "${output}" /etc/default/libc-locales; then
# echo not found: "${output}"
#elif grep -i -q "${output}" /etc/default/libc-locales; then
# echo exact match please: "${output}"
# grep -i "${output}" /etc/default/libc-locales | sed 's/.UTF-8//' | awk '{print $1}' | sed 's/#//'
#fi
done
source "${modules}"/40-"${modulename}"/langs/"${lang_tmp}".mod
addpkg base-system void-repo-multilib void-repo-multilib-nonfree void-repo-nonfree btrfs-progs lvm2 cronie socklog-void ntp xtools sudo wireguard-tools gnupg2 progress pwgen net-tools ncdu nmap mtr ioping iotop hdparm smartmontools htop git
servicesenable acpid cronie socklog-unix nanoklogd uuidd
servicesdisable agetty-tty6 agetty-tty5
module end

View File

@ -0,0 +1,30 @@
module start "bootloader" "Install Bootloader"
source "${vars}/disk"
diskid="${cfg[diskid]//-/_}"
if [[ "${cfg[fde_key_store]}" == "initramfs" ]] || [[ "${cfg[fde_key_store]}" == "usb" ]]; then
if ! grep -q "GRUB_ENABLE_CRYPTODISK" "${dest}"/etc/default/grub; then
echo "GRUB_ENABLE_CRYPTODISK=y" >> "${dest}"/etc/default/grub
fi
if [[ ! -f "${dest}"/boot/volume.key ]]; then
dd bs=1 count=64 if=/dev/urandom of="${dest}"/boot/volume.key
echo -n "${cfg[diskpw]}" | cryptsetup luksAddKey "${cfg[diskname]}${cfg[target_part]}" "${dest}"/boot/volume.key -d -
chmod 000 "${dest}"/boot/volume.key
chmod -R g-rwx,o-rwx "${dest}"/boot
fi
fi
if ! grep -q rd.lvm.vg "${dest}"/etc/default/grub; then
sed -i "/^GRUB_CMDLINE_LINUX_DEFAULT/s/=\"/=\"rd.lvm.vg=voidvg.${diskid} rd.luks.uuid=${cfg[partuuid]} rd.vconsole.keymap=${cfg[lang_console]} /" "${dest}"/etc/default/grub
fi
if [[ "${cfg[fde_key_store]}" == "initramfs" ]]; then
mkdir -p "${dest}"/etc/dracut.conf.d/
echo 'install_items+=" /boot/volume.key /etc/crypttab "' > "${dest}"/etc/dracut.conf.d/crypt-ssh.conf
echo "voidluks-${diskid} UUID=${cfg[partuuid]} /boot/volume.key luks" > "${dest}"/etc/crypttab
fi
module end

View File

@ -0,0 +1,8 @@
module start "bootloader" "Install Bootloader"
source "${vars}/disk"
grub-install "${cfg[diskname]}"
grub-mkconfig -o /boot/grub/grub.cfg
module end

View File

@ -0,0 +1,5 @@
module start "bootloader" "Configure Bootloader"
addpkg "grub"
module end

16
modules/60-network/pre Normal file
View File

@ -0,0 +1,16 @@
module "start" "network" "Network Configure"
multiplechoice "networksystem" "networkmanager" "dhcpcd" "none"
if [[ "${cfg[networksystem]}" == "networkmanager" ]]; then
addpkg "dbus" "NetworkManager"
servicesenable "dbus" "NetworkManager"
servicesdisable "dhcpcd"
elif [[ "${cfg[networksystem]}" == "dhcpcd" ]]; then
addpkg "dhcpcd"
servicesenable "dhcpcd"
elif [[ "${cfg[networksystem]}" == "none" ]]; then
echo "nothing selected"
fi
module "end"

13
modules/70-de/install Normal file
View File

@ -0,0 +1,13 @@
module start "de" "Desktopenvironment install"
if [[ ! "${cfg[de]}" == "none" ]]; then
test -f "${modules}"/"${modulename}".d/install/de/"${cfg[de]}".mod && source "${modules}"/"${modulename}".d/install/de/"${cfg[de]}".mod
test -f "${modules}"/"${modulename}".d/install/system/"${cfg[gfx_system]}".mod && source "${modules}"/"${modulename}".d/install/system/"${cfg[gfx_system]}".mod
test -f "${dest}"/etc/locale-user.conf && cp "${dest}"/etc/locale-user.conf "${dest}"/etc/sv/${cfg[dm]}/conf
fi
if [[ "${cfg[soundsystem]}" == "pipewire" ]]; then
source "${modules}"/"${modulename}".d/install/sound/"${cfg[soundsystem]}".mod
fi
module end

25
modules/70-de/pre Normal file
View File

@ -0,0 +1,25 @@
module "start" "de" "Desktopenvironment Configure"
setconf "add" "gfx_system" "xorg"
multiplechoice "de" "kde5" "i3wm" "gnome" "none"
multiplechoice "gfx_hardware" "amd" "nvidia" "intel" "none"
multiplechoice "soundsystem" "pulseaudio" "pipewire" "none"
if [[ ! "${cfg[soundsystem]}" == "none" ]]; then
addpkg "alsa-utils"
servicesenable "alsa"
test -f "${modules}"/"${modulename}".d/install/sound/"${cfg[soundsystem]}".mod && source "${modules}"/"${modulename}".d/install/sound/"${cfg[soundsystem]}".mod
fi
if [[ ! "${cfg[de]}" == "none" ]]; then
addpkg "firefox" "firefox-i18n-de" "browserpass" "vlc" "avahi"
servicesdisable "acpid"
servicesenable "avahi-daemon"
test -f "${modules}"/de.d/pre/de/"${cfg[de]}".mod && source "${modules}"/de.d/pre/de/"${cfg[de]}".mod
test -f "${modules}"/de.d/pre/system/"${cfg[gfx_system]}".mod && source "${modules}"/de.d/pre/system/"${cfg[gfx_system]}".mod
test -f "${modules}"/de.d/pre/gfx/"${cfg[gfx_hardware]}".mod && source "${modules}"/de.d/pre/gfx/"${cfg[gfx_hardware]}".mod
test -f "${modules}"/de.d/pre/cupsd.mod && source "${modules}"/de.d/pre/cupsd.mod
fi
module "end"

View File

@ -0,0 +1,9 @@
module start "laptop" "Laptopmode Install"
if [[ ! -z "${cfg[laptop]}" ]] && [[ "${cfg[de]}" == "none" ]]; then
echo "${modulename}"
#sed -i "/HandleLidSwitch/s/^#//g" "${dest}/etc/elogind/logind.conf"
#echo sed -i "/HandleLidSwitch/s/^#//g" "${dest}/etc/elogind/logind.conf"
fi
module end

8
modules/80-laptop/pre Normal file
View File

@ -0,0 +1,8 @@
module "start" "laptop" "Laptopmode Configure"
if yesno "Is this a laptop?" "n"; then
setconf add "laptop" "1"
addpkg laptop-mode
fi
module end

View File

@ -0,0 +1,25 @@
module start "services" "Enable and Disable services"
for i in "${services_enable[@]}"; do
[[ "${i}" == "dbus" ]] && dbus=1
done
if [[ "${#services_enable[@]}" -gt 0 ]]; then
test -z "${dbus}" || test -L "${dest}"/etc/runit/runsvdir/default/"${i}" || ln -s /etc/sv/"${i}" "${dest}"/etc/runit/runsvdir/default/
for i in "${services_enable[@]}"; do
#touch "${dest}"/etc/sv/"${i}"/down
test -h "${dest}"/etc/runit/runsvdir/default/"${i}" || ln -s /etc/sv/"${i}" "${dest}"/etc/runit/runsvdir/default/
done
fi
if [[ "${#services_disable[@]}" -gt 0 ]]; then
for i in "${services_disable[@]}"; do
test -h "${dest}"/etc/runit/runsvdir/default/"${i}" && rm -rf "${dest}"/etc/runit/runsvdir/default/"${i}"
done
fi
module end

View File

@ -0,0 +1,9 @@
module start "i3" "i3 Desktopenvironment Install"
mkdir -p "${dest}"/etc/X11/xinit/xinitrc.d/
echo 'if which dbus-launch >/dev/null && test -z "$DBUS_SESSION_BUS_ADDRESS"; then' > "${dest}"/etc/X11/xinit/xinitrc.d/dbus-launch.sh
echo ' eval "$(dbus-launch --sh-syntax --exit-with-x11)"' >> "${dest}"/etc/X11/xinit/xinitrc.d/dbus-launch.sh
echo 'fi' >> "${dest}"/etc/X11/xinit/xinitrc.d/dbus-launch.sh
chmod +x "${dest}"/etc/X11/xinit/xinitrc.d/dbus-launch.sh
module end

View File

@ -0,0 +1,10 @@
module start "pipewire" "Pipewire Install"
mkdir -p "${dest}"/etc/alsa/conf.d
ln -sf /usr/share/alsa/alsa.conf.d/50-pipewire.conf "${dest}"/etc/alsa/conf.d
ln -sf /usr/share/alsa/alsa.conf.d/99-pipewire-default.conf "${dest}"/etc/alsa/conf.d
mkdir -p "${dest}"/etc/ld.so.conf.d/
echo "/usr/lib/pipewire-0.3/jack" > "${dest}"/etc/ld.so.conf.d/zpipewire-jack.conf
ldconfig
module end

View File

@ -0,0 +1,4 @@
echo not implemented
return
MOZ_ENABLE_WAYLAND=1

View File

@ -0,0 +1,12 @@
module start "de-nodead" "xorg set lang de-nodead"
mkdir -p "${dest}"/etc/X11/xorg.conf.d
{ echo "Section \"InputClass\"";
echo " Identifier \"keyboard\"";
echo " MatchIsKeyboard \"yes\"";
echo " Option \"XkbLayout\" \"de\"";
echo " Option \"XkbVariant\" \"nodeadkeys\"";
echo " #Option \"XkbOptions\" \"grp:alt_shift_toggle\"";
echo "EndSection"; } > "${dest}"/etc/X11/xorg.conf.d/10-keyboard.conf
module end

View File

@ -0,0 +1,12 @@
module start "xorg" "xorg set lang de"
mkdir -p "${dest}"/etc/X11/xorg.conf.d
{ echo "Section \"InputClass\"";
echo " Identifier \"keyboard\"";
echo " MatchIsKeyboard \"yes\"";
echo " Option \"XkbLayout\" \"de\"";
echo " #Option \"XkbVariant\" \"nodeadkeys\"";
echo " #Option \"XkbOptions\" \"grp:alt_shift_toggle\"";
echo "EndSection"; } >> "${dest}"/etc/X11/xorg.conf.d/10-keyboard.conf
module end

View File

@ -0,0 +1,9 @@
module start "xorg" "XOrg Window System Install"
if [[ "${cfg[lang]}" == "de_DE" ]]; then
lang="de-nodead"
fi
[[ ! -h "${dest}"/etc/fonts/conf.d/70-no-bitmaps.conf ]] && ln -s /usr/share/fontconfig/conf.avail/70-no-bitmaps.conf "${dest}"/etc/fonts/conf.d/
source "${modules}"/de.d/install/system/"${modulename}".d/"${lang}".mod
module end

View File

@ -0,0 +1,6 @@
module start "cups" "Printing Configure"
addpkg cups cups-filters gutenprint hplip foomatic-db
servicesenable cupsd
module end

View File

@ -0,0 +1,7 @@
module start "gnome" "Gnome Desktopenvironment Configure"
setconf add "dm" "gdm"
addpkg "${cfg[dm]}" "${modulename}"
servicesenable "${cfg[dm]}" dbus
module end

View File

@ -0,0 +1,9 @@
module start "i3" "i3 Desktopenvironment Configure"
setconf add "dm" "lightdm"
addpkg "${cfg[dm]}" "${cfg[dm]}"-gtk3-greeter i3-gaps i3lock-color i3status xfce4-terminal \
dmenu rofi pcmanfm dunst elogind gvfs gvfs-afc gvfs-afp gvfs-cdda paprefs pavucontrol \
gvfs-gphoto2 gvfs-mtp gvfs-smb xss-lock claws-mail galculator-gtk3
servicesenable "${cfg[dm]}" dbus
module end

View File

@ -0,0 +1,8 @@
module start "kde5" "Plasma Desktopenvironment Configure"
setconf add "dm" "sddm"
addpkg "${cfg[dm]}" "${modulename}" kde5-baseapps kdegraphics-thumbnailers ffmpegthumbs ark \
gwenview kmail okular spectacle kalarm kcalc kdeconnect
servicesenable "${cfg[dm]}" dbus
module end

View File

@ -0,0 +1 @@
addpkg mesa-vulkan-radeon xf86-video-amdgpu mesa-vaapi mesa-vdpau

View File

@ -0,0 +1 @@
addpkg mesa-vulkan-intel xf86-video-intel intel-video-accel

View File

View File

@ -0,0 +1,3 @@
module start "pipewire" "Pipewire Configure"
addpkg pipewire alsa-pipewire libjack-pipewire libspa-jack
module end

View File

@ -0,0 +1,5 @@
module start "pulseaudio" "Pulseaudio Configure"
addpkg alsa-plugins-pulseaudio pulseaudio
module end

View File

@ -0,0 +1,15 @@
echo not implemented
return
modulname="wayland"
startmodul config "${modulname}"
pkg+=( qt5-wayland )
postrun_modules+=( "70-de.mod.de/system/${modulname}" )
#ignore+=()
#services_enable+=()
#services_disable+=()
cat <<'EOF'>> "${postinstall}"
startmodul post "wayland"
MOZ_ENABLE_WAYLAND=1
EOF

View File

@ -0,0 +1,6 @@
module start "xorg" "XOrg Window System Configure"
addpkg xorg-minimal xorg-fonts mesa-dri vulkan-loader xorg-apps
ignorepkg font-adobe-75dpi font-adobe-100dpi
module end

19
run_in_chroot.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/bash
dir="/tmp/installer"
wrksrc="${dir}"/tmp
functions="${dir}/functions"
modules="${dir}/modules"
config_mods="${modules}/config"
install_mods="${modules}/install"
chroot_mods="${modules}/chroot"
vars="${wrksrc}/vars"
declare -A cfg=()
declare -A users=()
#set -x
source "${functions}"/functions
export run="post"
for i in $(find "${modules}" -mindepth 1 -maxdepth 1 -type d | sort -n); do
test -f "${i}"/post && source "${i}"/post
done