dotfiles-guix/guix-strap/guix-configure

50 lines
1 KiB
Text
Raw Normal View History

2023-10-07 20:59:12 +00:00
#!/run/current-system/profile/bin/bash
source ./guix-log
source ./guix-env
HOSTNAME=""
CRYPT_UUID=""
EFI_UUID=""
get_uuid() {
blkid -s UUID -o value $1
}
CRYPT_UUID=$(get_uuid $CRYPT_PARTITION)
EFI_UUID=$(get_uuid $EFI_PARTITION)
get_hostname() {
CONFIRM=""
read -p "Enter system hostname: " HOSTNAME
if [ ! -z "$HOSTNAME" -a "$HOSTNAME" != " " ]; then
(confirm "$HOSTNAME");
if [ "$?" -ne 0 ]; then
get_hostname
fi
else
ERROR "'$HOSTNAME' is not a valid hostname"
fi
}
EVENT "Getting hostname"
get_hostname
EVENT "Hostname set to '$HOSTNAME'"
EVENT "Generating system config file"
cp system.scm "$HOSTNAME.scm"
sed -i "s/SED_CRYPT_UUID/$CRYPT_UUId/" ./$HOSTNAME.scm
sed -i "s/SED_EFI_UUID/$EFI_UUID/" ./$HOSTNAME.scm
sed -i "s/SED_HOSTNAME/$HOSTNAME/" ./$HOSTNAME.scm
mv "$HOSTNAME.scm" ..
EVENT "Successfully configured $HOSTNAME.scm"
echo "HOSTNAME=\"$HOSTNAME\"" >> ./guix-env
echo "CRYPT_UUID=\"$CRYPT_UUID\"" >> ./guix-env
echo "EFI_UUID=\"$EFI_UUID\"" >> ./guix-env