Skip to content

Commit 2aa2391

Browse files
committed
Add stepmania user.
1 parent 616d58a commit 2aa2391

File tree

4 files changed

+69
-7
lines changed

4 files changed

+69
-7
lines changed

after-pacstrap.sh

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,18 @@
88
source constants.sh
99
source helpers.sh
1010

11+
PASSWORD=
12+
13+
user_setup() {
14+
echo -e "${GREEN}Creating new user${NC}"
15+
useradd -m -G wheel $USERNAME
16+
echo ${USERNAME}:${PASSWORD} | chpasswd -e
17+
}
18+
1119
build_stepmania() {
1220
echo -e "${GREEN}Building StepMania${NC}"
21+
begin_checked_section
22+
1323
git clone --depth=1 https://github.com/stepmania/stepmania.git /stepmania
1424
mkdir /stepmania/build
1525
pushd /stepmania
@@ -25,20 +35,25 @@ build_stepmania() {
2535
cmake --install build --strip
2636
popd
2737
rm -rf /stepmania
38+
chown -R ${USERNAME}:${USERNAME} /opt/stepmania-5.1/
39+
40+
end_checked_section
2841
}
2942

3043
configure_settings() {
3144
echo -e "${GREEN}Setting up configuration files${NC}"
45+
begin_checked_section
3246

3347
# Set initial configuration for StepMania
3448
mkdir -p /opt/stepmania-5.1/Data
3549
cat <<EOF >> /opt/stepmania-5.1/Data/Static.ini
3650
[Options]
3751
Windowed=0
3852
EOF
53+
chown ${USERNAME}:${USERNAME} /opt/stepmania-5.1/Data/Static.ini
3954

4055
# Run stepmania when `startx` is run
41-
cat <<EOF > ~/.xinitrc
56+
cat <<EOF > /home/${USERNAME}/.xinitrc
4257
#!/bin/sh
4358
4459
if [ -d /etc/X11/xinit/xinitrc.d ]; then
@@ -50,24 +65,29 @@ fi
5065
5166
exec /opt/stepmania-5.1/stepmania
5267
EOF
68+
chown ${USERNAME}:${USERNAME} /home/${USERNAME}/.xinitrc
5369

5470
# Automatically login as root
5571
mkdir -p /etc/systemd/system/[email protected]
5672
cat <<EOF > /etc/systemd/system/[email protected]/override.conf
5773
[Service]
5874
ExecStart=
59-
ExecStart=-/usr/bin/agetty --skip-login --nonewline --noissue --autologin root --noclear %I \$TERM
75+
ExecStart=-/usr/bin/agetty --skip-login --nonewline --noissue --autologin $USERNAME --noclear %I \$TERM
6076
EOF
6177

6278
# Start X after login on tty1
63-
cat <<EOF > ~/.bash_profile
79+
cat <<EOF > /home/${USERNAME}/.bash_profile
6480
if [[ -z \$DISPLAY ]] && [[ \$(tty) = /dev/tty1 ]]; then
6581
startx -- -nocursor &>/dev/null
6682
fi
6783
EOF
84+
chown ${USERNAME}:${USERNAME} /home/${USERNAME}/.bash_profile
6885

6986
# Disable `Last login...` message
70-
touch ~/.hushlogin
87+
touch /home/${USERNAME}/.hushlogin
88+
chown ${USERNAME}:${USERNAME} /home/${USERNAME}/.hushlogin
89+
90+
end_checked_section
7191
}
7292

7393
timezone_setup() {
@@ -84,6 +104,9 @@ locale_setup() {
84104
}
85105

86106
initramfs_setup() {
107+
echo -e "${GREEN}Rebuilding initramfs${NC}"
108+
begin_checked_section
109+
87110
# Compress with lz4
88111
echo COMPRESSION=\"lz4\" >> /etc/mkinitcpio.conf
89112
echo COMPRESSION_OPTIONS=\"-9\" >> /etc/mkinitcpio.conf
@@ -118,10 +141,14 @@ EOF
118141

119142
# Rebuild initramfs
120143
mkinitcpio -p linux
144+
145+
end_checked_section
121146
}
122147

123148
bootloader_setup() {
124149
echo -e "${GREEN}Setting up bootloader${NC}"
150+
begin_checked_section
151+
125152
bootctl install
126153
local uuid=$(cat $UUID_PATH)
127154
cat <<EOF > /boot/loader/loader.conf
@@ -154,13 +181,26 @@ EOF
154181
if [[ "$(sha256sum /boot/EFI/systemd/systemd-bootx64.efi | cut -d' ' -f1)" == "$checksum" ]]; then
155182
echo -ne "\x90\x90\x90\x90\x90" | dd of=/boot/EFI/systemd/systemd-bootx64.efi bs=1 seek=40320 count=5 conv=notrunc
156183
fi
184+
185+
end_checked_section
157186
}
158187

159188
cleanup() {
189+
echo -e "${GREEN}Cleaning up${NC}"
160190
rm -rf /var/cache/pacman/pkg
161191
touch /tmp/success
162192
}
163193

194+
# Parse arguments
195+
while [[ "$1" != "" ]]; do
196+
case $1 in
197+
--password ) shift; PASSWORD=$1 ;;
198+
* ) echo "Invalid argument \"$1\""; exit 1 ;;
199+
esac
200+
shift
201+
done
202+
203+
user_setup
164204
build_stepmania
165205
configure_settings
166206
timezone_setup

constants.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ else
1515
exit 1
1616
fi
1717
readonly UUID_PATH='/uuid.tmp'
18+
readonly USERNAME='stepmania'
1819

1920
# Change these variables as needed
2021
readonly KEYMAP='us'

helpers.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ arch_chroot() {
3232
arch-chroot /mnt /bin/bash -c "${1}"
3333
}
3434

35+
installation_canceled() {
36+
echo -e "${RED}Installation canceled.${NC}"
37+
exit 1
38+
}
39+
3540
# Wrap one or more commands around `begin_checked_section` and
3641
# `end_checked_section` to exit the script early if any of the commands fail.
3742
#

install.sh

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,26 @@
33
source constants.sh
44
source helpers.sh
55

6+
PASSWORD= # Set by user_setup()
67

78
#
89
# Main Functions
910
#
11+
user_setup() {
12+
password1=$(whiptail --passwordbox "Enter password for user 'stepmania':" 8 50 3>&1 1>&2 2>&3)
13+
if ! [[ "$?" == "0" ]]; then installation_canceled; fi
14+
15+
password2=$(whiptail --passwordbox "Confirm password:" 8 50 3>&1 1>&2 2>&3)
16+
if ! [[ "$?" == "0" ]]; then installation_canceled; fi
17+
18+
if [[ "$password1" == "$password2" ]]; then
19+
PASSWORD=$(openssl passwd -6 "$password1")
20+
return 0
21+
else
22+
whiptail --msgbox "Passwords do not match, try again." 0 0
23+
user_setup # Prompt again.
24+
fi
25+
}
1026
disk_setup() {
1127
umount -R /mnt &>/dev/null
1228
local drive_list=$(lsblk -dnlpo NAME,MODEL -e 7,11)
@@ -51,8 +67,7 @@ disk_setup() {
5167
exit 0
5268
fi
5369
else
54-
echo Installation canceled.
55-
exit 0
70+
installation_canceled
5671
fi
5772
}
5873

@@ -83,7 +98,7 @@ after_pacstrap() {
8398
begin_checked_section
8499
mkdir -p /mnt/after-pacstrap
85100
cp after-pacstrap.sh constants.sh helpers.sh /mnt/after-pacstrap
86-
arch-chroot /mnt bash -c "cd /after-pacstrap && source after-pacstrap.sh"
101+
arch-chroot /mnt bash -c "cd /after-pacstrap && bash after-pacstrap.sh --password '$PASSWORD'"
87102
rm -rf /mnt/after-pacstrap
88103
end_checked_section
89104

@@ -106,6 +121,7 @@ finished() {
106121
check_root
107122
check_internet_connection
108123

124+
user_setup
109125
disk_setup
110126
package_setup
111127
fstab_setup

0 commit comments

Comments
 (0)