Compare commits
19 Commits
eacadeba2a
...
master
Author | SHA1 | Date | |
---|---|---|---|
985d8bc7b9 | |||
856c794637 | |||
1257eb31ab | |||
adfc259d0f | |||
4c8de812ba | |||
f1a802ad66 | |||
9f38eb89bd | |||
c04f9ac7c4 | |||
29de9dd990 | |||
41f91fc610 | |||
419522c475 | |||
0606966eac | |||
24415b0328 | |||
3593fe6702 | |||
e51940bf86 | |||
12e45ded37 | |||
bf36a89324 | |||
57a0fddce7 | |||
f8044c0a98 |
@ -2,7 +2,7 @@
|
||||
# Configure Stormux
|
||||
# A script to configure the system for new users.
|
||||
#
|
||||
# Copyright 2020, Storm Dragon, <storm_dragon@linux-a11y.org>
|
||||
# Copyright 2020, 2025, Storm Dragon, <storm_dragon@stormux.org>
|
||||
#
|
||||
# This is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU General Public License as published by the Free
|
||||
@ -18,48 +18,94 @@
|
||||
# along with this package; see the file COPYING. If not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
# 02110-1301, USA.
|
||||
#
|
||||
#--code--
|
||||
|
||||
source ./.includes/functions.sh
|
||||
source ./.includes/ui.sh
|
||||
|
||||
# The user can not be logged in when the name change occurs.
|
||||
# Write a file to /etc/cron.d/chuser
|
||||
# The file will run at boot, change the username, and delete itself.
|
||||
if [[ $# -ne 1 ]]; then
|
||||
msgbox "Missing required argument: new username."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ $# -ne 1 ]]; then
|
||||
msgbox "Missing required argument, username."
|
||||
exit 1
|
||||
if [[ "$(whoami)" == "root" ]]; then
|
||||
msgbox "Please run this script as the user you would like to migrate from, not as root."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
newUser="$1"
|
||||
oldUser="$USER"
|
||||
|
||||
if ! [[ "$newUser" =~ ^[a-z][-a-z0-9]*$ ]]; then
|
||||
msgbox "Username $newUser failed validation. It cannot contain spaces or special characters."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if id "$newUser" &> /dev/null; then
|
||||
msgbox "User $newUser already exists. Aborting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$(yesno "This will create a new user named $newUser and migrate your current settings and files. Continue?")" == "No" ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
while : ; do
|
||||
password1=$(passwordbox "Enter a password for $newUser:")
|
||||
password2=$(passwordbox "Confirm the password:")
|
||||
if [[ "$password1" != "$password2" ]]; then
|
||||
msgbox "Passwords do not match. Please try again."
|
||||
elif [[ -z "$password1" ]]; then
|
||||
msgbox "Password cannot be empty."
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ "$(whoami)" == "root" ]]; then
|
||||
msgbox "Please run this script as the user you would like to rename, not as root."
|
||||
exit 1
|
||||
fi
|
||||
infobox "Creating user $newUser..."
|
||||
|
||||
oldUser="$USER"
|
||||
userGroups="$(id -Gn "$oldUser" | tr ' ' ',')"
|
||||
if ! sudo "${sudoFlags[@]}" useradd -m -G "$userGroups" "$newUser"; then
|
||||
msgbox "Failed to create user $newUser. Aborting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
groups="$(groups "$oldUser")"
|
||||
groups="${groups// /,}"
|
||||
# Set the password
|
||||
echo "$newUser:$password1" | sudo "${sudoFlags[@]}" chpasswd
|
||||
|
||||
newUser="$1"
|
||||
if ! [[ "$newUser" =~ ^[a-z][-a-z0-9]*$ ]]; then
|
||||
msgbox "Username $newUser failed validation. It cannot contain spaces or some punctuation."
|
||||
exit 1
|
||||
fi
|
||||
# Change the active nodm user
|
||||
sudo "${sudoFlags[@]}" sed -i -e "s#NODM_USER=.*#NODM_USER='$newUser'#" -e "s#NODM_XSESSION=.*#NODM_XSESSION='/home/$newUser/.xinitrc'#" /etc/nodm.conf
|
||||
|
||||
# Heredocument left-aligned
|
||||
cat << EOF | sudo "${sudoFlags[@]}" tee /etc/cron.d/0chuser &> /dev/null
|
||||
SHELL=/bin/bash
|
||||
PATH=/sbin:/bin:/usr/sbin:/usr/bin
|
||||
@reboot root usermod -a -G $groups -m -d /home/$newUser -l $newUser $oldUser && sed -i -e "s#NODM_USER=.*#NODM_USER='$newUser'#" -e "s#NODM_XSESSION=.*#NODM_XSESSION='/home/$newUser/.xinitrc'#" /etc/nodm.conf; rm -f /etc/cron.d/0chuser;reboot
|
||||
infobox "Copying your home directory to /home/$newUser, this may take some time..."
|
||||
sudo "${sudoFlags[@]}" cp -a "/home/$oldUser/." "/home/$newUser/"
|
||||
sudo "${sudoFlags[@]}" chown -R "$newUser:$newUser" "/home/$newUser"
|
||||
|
||||
infobox "Updating linger settings..."
|
||||
sudo "${sudoFlags[@]}" touch "/var/lib/systemd/linger/$newUser"
|
||||
sudo "${sudoFlags[@]}" rm -f "/var/lib/systemd/linger/$oldUser"
|
||||
|
||||
infobox "Replacing references to $oldUser in config files. This may take some time..."
|
||||
sudo "${sudoFlags[@]}" find "/home/$newUser" -type f -exec sed -i "s|$oldUser|$newUser|g" {} +
|
||||
|
||||
# Optionally remove the old user.
|
||||
if [[ "$(yesno "Do you want to delete $oldUser on next reboot?")" == "Yes" ]]; then
|
||||
# Dynamically create the systemd service to remove the old user at boot
|
||||
cat << EOF | sudo tee /etc/systemd/system/remove-olduser.service > /dev/null
|
||||
[Unit]
|
||||
Description=Remove old user after renaming
|
||||
After=multi-user.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/sbin/userdel -r $oldUser
|
||||
ExecStartPost=/bin/systemctl disable remove-olduser.service
|
||||
ExecStartPost=/bin/rm -f /etc/systemd/system/remove-olduser.service
|
||||
RemainAfterExit=true
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
# Heredocument end.
|
||||
|
||||
# Make sure sound services start for the new user.
|
||||
mkdir -p /var/lib/systemd/linger
|
||||
sudo mv -v "/var/lib/systemd/linger/$oldUser" "/var/lib/systemd/linger/$newUser"
|
||||
|
||||
# Files in cron.d must be 644 to work.
|
||||
sudo "${sudoFlags[@]}" chmod 644 /etc/cron.d/0chuser
|
||||
|
||||
# Enable the service to run at boot
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable remove-olduser.service
|
||||
fi
|
||||
|
@ -26,3 +26,108 @@ if dialog --clear --backtitle "Stormux" --yesno "Would you like to reboot now to
|
||||
attention() {
|
||||
play -qnV0 synth 3 pluck D3 pluck A3 pluck D4 pluck F4 pluck A4 delay 0 .1 .2 .3 .4 remix - chorus 0.9 0.9 38 0.75 0.3 0.5 -t
|
||||
}
|
||||
|
||||
add_stormux_repo() {
|
||||
# Check if StormUX repository is already configured
|
||||
if grep -q "aarch64.stormux.org" /etc/pacman.conf; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
infobox "Adding StormUX repository and importing signing key..."
|
||||
|
||||
# Import the repository signing key
|
||||
if ! curl -s https://aarch64.stormux.org/stormux-repo.pub | sudo "${sudoFlags[@]}" pacman-key --add -; then
|
||||
msgbox "Failed to download StormUX repository key."
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Locally sign the key
|
||||
if ! sudo "${sudoFlags[@]}" pacman-key --lsign-key storm_dragon@stormux.org; then
|
||||
msgbox "Failed to sign StormUX repository key."
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Add repository to pacman.conf before any AUR-related sections
|
||||
# Create a temporary file with the repository configuration
|
||||
local temp_conf=$(mktemp)
|
||||
local added_repo=false
|
||||
|
||||
while IFS= read -r line; do
|
||||
# Add StormUX repo before any AUR or custom repo sections
|
||||
if [[ "$line" =~ ^\[.*\]$ ]] && [[ ! "$line" =~ ^\[(core|extra|multilib|testing|multilib-testing)\]$ ]] && [[ "$added_repo" == false ]]; then
|
||||
echo "[stormux]" >> "$temp_conf"
|
||||
echo "SigLevel = Required" >> "$temp_conf"
|
||||
echo "Server = https://aarch64.stormux.org/" >> "$temp_conf"
|
||||
echo "" >> "$temp_conf"
|
||||
added_repo=true
|
||||
fi
|
||||
echo "$line" >> "$temp_conf"
|
||||
done < /etc/pacman.conf
|
||||
|
||||
# If we didn't add it yet (no custom repos found), add it at the end
|
||||
if [[ "$added_repo" == false ]]; then
|
||||
echo "" >> "$temp_conf"
|
||||
echo "[stormux]" >> "$temp_conf"
|
||||
echo "SigLevel = Required" >> "$temp_conf"
|
||||
echo "Server = https://aarch64.stormux.org/\$repo-\$arch" >> "$temp_conf"
|
||||
fi
|
||||
|
||||
# Replace the original pacman.conf
|
||||
if ! sudo "${sudoFlags[@]}" cp "$temp_conf" /etc/pacman.conf; then
|
||||
rm -f "$temp_conf"
|
||||
msgbox "Failed to update pacman.conf with StormUX repository."
|
||||
return 1
|
||||
fi
|
||||
|
||||
rm -f "$temp_conf"
|
||||
|
||||
# Refresh package databases
|
||||
if ! sudo "${sudoFlags[@]}" pacman -Syy; then
|
||||
msgbox "Failed to refresh package databases after adding StormUX repository."
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
install_xlibre() {
|
||||
# Make sure system is up to date
|
||||
yay --sudoflags "${sudoFlags[@]}" --sudoloop --noconfirm -Syu
|
||||
|
||||
# Check if we have internet connectivity
|
||||
if ! ping -c1 stormux.org &>/dev/null; then
|
||||
msgbox "No internet connection detected. X11Libre installation requires internet access."
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Add StormUX repository with proper key management
|
||||
if ! add_stormux_repo; then
|
||||
msgbox "Failed to add StormUX repository. Installation aborted."
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Remove conflicting packages
|
||||
infobox "Removing conflicting Xorg packages..."
|
||||
sudo "${sudoFlags[@]}" pacman -R --noconfirm xorg-server xf86-input-libinput xf86-video-fbdev 2>/dev/null || true
|
||||
|
||||
# Install X11Libre packages from StormUX repository
|
||||
infobox "Installing X11Libre server and drivers..."
|
||||
if ! sudo "${sudoFlags[@]}" pacman -S --noconfirm xlibre-server-common xlibre-server-devel; then
|
||||
msgbox "Failed to install X11Libre server components."
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ! sudo "${sudoFlags[@]}" pacman -Sdd --noconfirm xlibre-server; then
|
||||
msgbox "Failed to install X11Libre server main package."
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Install input and video drivers from StormUX repository
|
||||
if ! sudo "${sudoFlags[@]}" pacman -S --noconfirm xlibre-input-libinput xlibre-video-dummy-with-vt xlibre-video-fbdev; then
|
||||
msgbox "Failed to install X11Libre input and video drivers."
|
||||
return 1
|
||||
fi
|
||||
|
||||
infobox "X11Libre installation completed successfully!"
|
||||
return 0
|
||||
}
|
||||
|
@ -14,18 +14,23 @@ case "${1}" in
|
||||
*) session="$1";;
|
||||
esac
|
||||
|
||||
./.includes/toggle-screen.sh
|
||||
install_package ${packages} firefox nodm-dgw orca speech-dispatcher xclip xorg-drivers xorg-server xorg-xinit
|
||||
./.includes/toggle-screen.sh -n
|
||||
|
||||
# Install X11Libre
|
||||
if ! install_xlibre; then
|
||||
msgbox "X11Libre installation failed. Installation aborted."
|
||||
return 1
|
||||
fi
|
||||
|
||||
# X11Libre installed successfully, install remaining packages
|
||||
# Note: nodm-dgw is now available from StormUX repository (added by install_xlibre)
|
||||
install_package ${packages} firefox nodm-dgw orca speech-dispatcher xclip xorg-xinit
|
||||
|
||||
# GUI bluetooth manager
|
||||
if [[ "${architecture}" == "aarch64" ]]; then
|
||||
install_package blueman
|
||||
fi
|
||||
|
||||
# replace xf86-video-dummy with xf86-video-dummy-with-vt
|
||||
yay --noconfirm -Rdd xf86-video-dummy
|
||||
url_install 'https://stormux.org/packages/xf86-video-dummy-with-vt-0.4.1-1-aarch64.pkg.tar.xz'
|
||||
|
||||
# Configure nodm
|
||||
sudo sed -i "s/{user}/$USER/g" /etc/nodm.conf
|
||||
|
||||
|
@ -14,54 +14,48 @@ EOF
|
||||
headless() {
|
||||
cat << EOF | sudo "${sudoFlags[@]}" tee /etc/X11/xorg.conf.d/10-screendriver.conf &> /dev/null
|
||||
Section "Monitor"
|
||||
Identifier "dummy_monitor"
|
||||
HorizSync 28.0-80.0
|
||||
VertRefresh 48.0-75.0
|
||||
Modeline "1920x1080" 172.80 1920 2040 2248 2576 1080 1081 1084 1118
|
||||
Identifier "dummy_monitor"
|
||||
HorizSync 28.0-80.0
|
||||
VertRefresh 48.0-75.0
|
||||
Modeline "1920x1080" 172.80 1920 2040 2248 2576 1080 1081 1084 1118
|
||||
EndSection
|
||||
|
||||
Section "Device"
|
||||
Identifier "dummy_card"
|
||||
VideoRam 256000
|
||||
Driver "dummy"
|
||||
Identifier "dummy_card"
|
||||
Driver "dummy"
|
||||
VideoRam 256000
|
||||
Option "UseFBDev" "false"
|
||||
EndSection
|
||||
|
||||
Section "Screen"
|
||||
Identifier "dummy_screen"
|
||||
Device "dummy_card"
|
||||
Monitor "dummy_monitor"
|
||||
SubSection "Display"
|
||||
EndSubSection
|
||||
EndSection
|
||||
[storm@fenrir ~] $ cat ~/99-headless.conf
|
||||
Section "Monitor"
|
||||
Identifier "dummy_monitor"
|
||||
HorizSync 28.0-80.0
|
||||
VertRefresh 48.0-75.0
|
||||
Modeline "1920x1080" 172.80 1920 2040 2248 2576 1080 1081 1084 1118
|
||||
Identifier "dummy_screen"
|
||||
Device "dummy_card"
|
||||
Monitor "dummy_monitor"
|
||||
SubSection "Display"
|
||||
Depth 24
|
||||
Modes "1920x1080"
|
||||
EndSubSection
|
||||
EndSection
|
||||
|
||||
Section "Device"
|
||||
Identifier "dummy_card"
|
||||
VideoRam 256000
|
||||
Driver "dummy"
|
||||
EndSection
|
||||
|
||||
Section "Screen"
|
||||
Identifier "dummy_screen"
|
||||
Device "dummy_card"
|
||||
Monitor "dummy_monitor"
|
||||
SubSection "Display"
|
||||
EndSubSection
|
||||
Section "ServerLayout"
|
||||
Identifier "dummy_layout"
|
||||
Screen 0 "dummy_screen"
|
||||
EndSection
|
||||
EOF
|
||||
}
|
||||
|
||||
|
||||
source ./.includes/functions.sh
|
||||
source ./.includes/ui.sh
|
||||
answer=$(yesno "Do you have a physical screen attached?")
|
||||
if [[ "${answer}" == "yes" ]]; then
|
||||
if [[ "${answer}" == "Yes" ]]; then
|
||||
active_screen
|
||||
msgbox "Settings for physical screen applied."
|
||||
else
|
||||
headless
|
||||
msgbox "Settings for no screen applied."
|
||||
fi
|
||||
|
||||
if [[ "$1" != "-n" ]]; then
|
||||
restart
|
||||
fi
|
||||
|
Reference in New Issue
Block a user