POSIX rewrite: chroot_setup.bash

This commit is contained in:
Syahrial Agni Prasetya 2021-05-27 17:23:25 +07:00
parent b7a8e12c6b
commit 4f5e1144df
No known key found for this signature in database
GPG Key ID: 46F88749C8C79383
2 changed files with 10 additions and 12 deletions

View File

@ -93,7 +93,7 @@ case $1 in
"${PREFIX}"/share/archbox/bin/init start "${PREFIX}"/share/archbox/bin/init start
cp "${PREFIX}"/share/archbox/chroot_setup.bash "${CHROOT}"/chroot_setup cp "${PREFIX}"/share/archbox/chroot_setup.bash "${CHROOT}"/chroot_setup
printf "%s" $ARCHBOX_USER > /tmp/archbox_user printf "%s" $ARCHBOX_USER > /tmp/archbox_user
chroot $CHROOT /bin/bash /chroot_setup chroot $CHROOT /bin/sh /chroot_setup
exit $? exit $?
;; ;;
-e|--enter) -e|--enter)

View File

@ -1,5 +1,3 @@
#!/bin/sh
. /etc/archbox.conf >/dev/null 2>&1 . /etc/archbox.conf >/dev/null 2>&1
set -- set --
@ -31,30 +29,30 @@ mkdir -p /usr/local/bin
curl https://raw.githubusercontent.com/lemniskett/archboxctl/master/archboxctl.bash > /usr/local/bin/archboxctl curl https://raw.githubusercontent.com/lemniskett/archboxctl/master/archboxctl.bash > /usr/local/bin/archboxctl
chmod 755 /usr/local/bin/archboxctl chmod 755 /usr/local/bin/archboxctl
msg "Setting up locale..." msg "Setting up locale..."
echo "Uncomment needed locale, enter to continue" printf "%s\n" "Uncomment needed locale, enter to continue"
read read
nano /etc/locale.gen nano /etc/locale.gen
locale-gen locale-gen
msg "Setting up timezone..." msg "Setting up timezone..."
echo "Enter your timezone, for example : \"Asia/Jakarta\"" printf "%s\n" "Enter your timezone, for example : \"Asia/Jakarta\""
while true; do while true; do
read TIMEZONE \ read TIMEZONE \
&& [[ -e /usr/share/zoneinfo/$TIMEZONE ]] \ && [ -e /usr/share/zoneinfo/$TIMEZONE ] \
&& ln -s /usr/share/zoneinfo/$TIMEZONE /etc/localtime \ && ln -s /usr/share/zoneinfo/$TIMEZONE /etc/localtime \
&& break \ && break \
|| echo "Timezone not found, enter it again." || printf "%s\n" "Timezone not found, enter it again."
done done
msg "Creating user account..." msg "Creating user account..."
CHROOT_USER="$(cat /tmp/archbox_user)" read CHROOT_USER < /tmp/archbox_user
useradd -m $CHROOT_USER useradd -m $CHROOT_USER
gpasswd -a $CHROOT_USER wheel usermod -aG wheel $CHROOT_USER
echo "Enter root password" printf "%s\n" "Enter root password"
while true; do while true; do
passwd && break passwd && break
done done
echo "Enter $CHROOT_USER password" printf "%s\n" "Enter $CHROOT_USER password"
while true; do while true; do
passwd $CHROOT_USER && break passwd $CHROOT_USER && break
done done
sed -i 's/# %wheel ALL=(ALL) NOPASSWD: ALL/%wheel ALL=(ALL) NOPASSWD: ALL/g' /etc/sudoers sed -i 's/# %wheel ALL=(ALL) NOPASSWD: ALL/%wheel ALL=(ALL) NOPASSWD: ALL/g' /etc/sudoers
echo "Don't forget to run \"archbox --mount\" in host on boot" printf "%s\n" "Don't forget to run \"archbox --mount\" in host on boot"