Compare commits
17 Commits
57a0fddce7
...
master
Author | SHA1 | Date | |
---|---|---|---|
985d8bc7b9 | |||
856c794637 | |||
1257eb31ab | |||
adfc259d0f | |||
4c8de812ba | |||
f1a802ad66 | |||
9f38eb89bd | |||
c04f9ac7c4 | |||
29de9dd990 | |||
41f91fc610 | |||
419522c475 | |||
0606966eac | |||
24415b0328 | |||
3593fe6702 | |||
e51940bf86 | |||
12e45ded37 | |||
bf36a89324 |
@ -2,7 +2,7 @@
|
|||||||
# Configure Stormux
|
# Configure Stormux
|
||||||
# A script to configure the system for new users.
|
# 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
|
# 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
|
# 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
|
# along with this package; see the file COPYING. If not, write to the Free
|
||||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||||
# 02110-1301, USA.
|
# 02110-1301, USA.
|
||||||
#
|
|
||||||
#--code--
|
|
||||||
|
|
||||||
|
source ./.includes/functions.sh
|
||||||
|
source ./.includes/ui.sh
|
||||||
|
|
||||||
# The user can not be logged in when the name change occurs.
|
if [[ $# -ne 1 ]]; then
|
||||||
# Write a file to /etc/cron.d/chuser
|
msgbox "Missing required argument: new username."
|
||||||
# The file will run at boot, change the username, and delete itself.
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ $# -ne 1 ]]; then
|
if [[ "$(whoami)" == "root" ]]; then
|
||||||
msgbox "Missing required argument, username."
|
msgbox "Please run this script as the user you would like to migrate from, not as root."
|
||||||
exit 1
|
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
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
if [[ "$(whoami)" == "root" ]]; then
|
infobox "Creating user $newUser..."
|
||||||
msgbox "Please run this script as the user you would like to rename, not as root."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
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")"
|
# Set the password
|
||||||
groups="${groups// /,}"
|
echo "$newUser:$password1" | sudo "${sudoFlags[@]}" chpasswd
|
||||||
|
|
||||||
newUser="$1"
|
# Change the active nodm user
|
||||||
if ! [[ "$newUser" =~ ^[a-z][-a-z0-9]*$ ]]; then
|
sudo "${sudoFlags[@]}" sed -i -e "s#NODM_USER=.*#NODM_USER='$newUser'#" -e "s#NODM_XSESSION=.*#NODM_XSESSION='/home/$newUser/.xinitrc'#" /etc/nodm.conf
|
||||||
msgbox "Username $newUser failed validation. It cannot contain spaces or some punctuation."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Heredocument left-aligned
|
infobox "Copying your home directory to /home/$newUser, this may take some time..."
|
||||||
cat << EOF | sudo "${sudoFlags[@]}" tee /etc/cron.d/0chuser &> /dev/null
|
sudo "${sudoFlags[@]}" cp -a "/home/$oldUser/." "/home/$newUser/"
|
||||||
SHELL=/bin/bash
|
sudo "${sudoFlags[@]}" chown -R "$newUser:$newUser" "/home/$newUser"
|
||||||
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 "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
|
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() {
|
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
|
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";;
|
*) session="$1";;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
./.includes/toggle-screen.sh
|
./.includes/toggle-screen.sh -n
|
||||||
install_package ${packages} firefox nodm-dgw orca speech-dispatcher xclip xorg-drivers xorg-server xorg-xinit
|
|
||||||
|
# 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
|
# GUI bluetooth manager
|
||||||
if [[ "${architecture}" == "aarch64" ]]; then
|
if [[ "${architecture}" == "aarch64" ]]; then
|
||||||
install_package blueman
|
install_package blueman
|
||||||
fi
|
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
|
# Configure nodm
|
||||||
sudo sed -i "s/{user}/$USER/g" /etc/nodm.conf
|
sudo sed -i "s/{user}/$USER/g" /etc/nodm.conf
|
||||||
|
|
||||||
|
@ -14,45 +14,32 @@ EOF
|
|||||||
headless() {
|
headless() {
|
||||||
cat << EOF | sudo "${sudoFlags[@]}" tee /etc/X11/xorg.conf.d/10-screendriver.conf &> /dev/null
|
cat << EOF | sudo "${sudoFlags[@]}" tee /etc/X11/xorg.conf.d/10-screendriver.conf &> /dev/null
|
||||||
Section "Monitor"
|
Section "Monitor"
|
||||||
Identifier "dummy_monitor"
|
Identifier "dummy_monitor"
|
||||||
HorizSync 28.0-80.0
|
HorizSync 28.0-80.0
|
||||||
VertRefresh 48.0-75.0
|
VertRefresh 48.0-75.0
|
||||||
Modeline "1920x1080" 172.80 1920 2040 2248 2576 1080 1081 1084 1118
|
Modeline "1920x1080" 172.80 1920 2040 2248 2576 1080 1081 1084 1118
|
||||||
EndSection
|
EndSection
|
||||||
|
|
||||||
Section "Device"
|
Section "Device"
|
||||||
Identifier "dummy_card"
|
Identifier "dummy_card"
|
||||||
VideoRam 256000
|
Driver "dummy"
|
||||||
Driver "dummy"
|
VideoRam 256000
|
||||||
|
Option "UseFBDev" "false"
|
||||||
EndSection
|
EndSection
|
||||||
|
|
||||||
Section "Screen"
|
Section "Screen"
|
||||||
Identifier "dummy_screen"
|
Identifier "dummy_screen"
|
||||||
Device "dummy_card"
|
Device "dummy_card"
|
||||||
Monitor "dummy_monitor"
|
Monitor "dummy_monitor"
|
||||||
SubSection "Display"
|
SubSection "Display"
|
||||||
EndSubSection
|
Depth 24
|
||||||
EndSection
|
Modes "1920x1080"
|
||||||
[storm@fenrir ~] $ cat ~/99-headless.conf
|
EndSubSection
|
||||||
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
|
|
||||||
EndSection
|
EndSection
|
||||||
|
|
||||||
Section "Device"
|
Section "ServerLayout"
|
||||||
Identifier "dummy_card"
|
Identifier "dummy_layout"
|
||||||
VideoRam 256000
|
Screen 0 "dummy_screen"
|
||||||
Driver "dummy"
|
|
||||||
EndSection
|
|
||||||
|
|
||||||
Section "Screen"
|
|
||||||
Identifier "dummy_screen"
|
|
||||||
Device "dummy_card"
|
|
||||||
Monitor "dummy_monitor"
|
|
||||||
SubSection "Display"
|
|
||||||
EndSubSection
|
|
||||||
EndSection
|
EndSection
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
@ -61,12 +48,14 @@ EOF
|
|||||||
source ./.includes/functions.sh
|
source ./.includes/functions.sh
|
||||||
source ./.includes/ui.sh
|
source ./.includes/ui.sh
|
||||||
answer=$(yesno "Do you have a physical screen attached?")
|
answer=$(yesno "Do you have a physical screen attached?")
|
||||||
if [[ "${answer}" == "yes" ]]; then
|
if [[ "${answer}" == "Yes" ]]; then
|
||||||
active_screen
|
active_screen
|
||||||
msgbox "Settings for physical screen applied."
|
msgbox "Settings for physical screen applied."
|
||||||
restart
|
|
||||||
else
|
else
|
||||||
headless
|
headless
|
||||||
msgbox "Headless mode applied."
|
msgbox "Settings for no screen applied."
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$1" != "-n" ]]; then
|
||||||
restart
|
restart
|
||||||
fi
|
fi
|
||||||
|
Reference in New Issue
Block a user