Fixes to the aarch64 stormux repository.
This commit is contained in:
111
.includes/chuser.sh.bak
Executable file
111
.includes/chuser.sh.bak
Executable file
@ -0,0 +1,111 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Configure Stormux
|
||||||
|
# A script to configure the system for new users.
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
# Software Foundation; either version 3, or (at your option) any later
|
||||||
|
# version.
|
||||||
|
#
|
||||||
|
# This software is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
source ./.includes/functions.sh
|
||||||
|
source ./.includes/ui.sh
|
||||||
|
|
||||||
|
if [[ $# -ne 1 ]]; then
|
||||||
|
msgbox "Missing required argument: new username."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
infobox "Creating user $newUser..."
|
||||||
|
|
||||||
|
userGroups="$(id -Gn "$oldUser" | tr ' ' ',')"
|
||||||
|
if ! sudo "${sudoFlags[@]}" useradd -m -G "$userGroups" "$newUser"; then
|
||||||
|
msgbox "Failed to create user $newUser. Aborting."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Set the password
|
||||||
|
echo "$newUser:$password1" | sudo "${sudoFlags[@]}" chpasswd
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
infobox "Copying your home directory to /home/$newUser..."
|
||||||
|
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 a moment."
|
||||||
|
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
|
||||||
|
|
||||||
|
# Enable the service to run at boot
|
||||||
|
sudo systemctl daemon-reload
|
||||||
|
sudo systemctl enable remove-olduser.service
|
||||||
|
fi
|
@ -28,11 +28,18 @@ attention() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
add_stormux_repo() {
|
add_stormux_repo() {
|
||||||
# Check if StormUX repository is already configured
|
# Check if StormUX repository is already configured correctly
|
||||||
if grep -q "aarch64.stormux.org" /etc/pacman.conf; then
|
if grep -q "aarch64.stormux.org/\$repo-\$arch" /etc/pacman.conf; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Check if old format exists and needs fixing
|
||||||
|
local needs_fixing=false
|
||||||
|
if grep -q "aarch64.stormux.org" /etc/pacman.conf && ! grep -q "aarch64.stormux.org/\$repo-\$arch" /etc/pacman.conf; then
|
||||||
|
needs_fixing=true
|
||||||
|
infobox "Updating StormUX repository configuration..."
|
||||||
|
fi
|
||||||
|
|
||||||
infobox "Adding StormUX repository and importing signing key..."
|
infobox "Adding StormUX repository and importing signing key..."
|
||||||
|
|
||||||
# Import the repository signing key
|
# Import the repository signing key
|
||||||
@ -53,11 +60,25 @@ add_stormux_repo() {
|
|||||||
local added_repo=false
|
local added_repo=false
|
||||||
|
|
||||||
while IFS= read -r line; do
|
while IFS= read -r line; do
|
||||||
|
# Skip existing stormux repository entries if we're fixing them
|
||||||
|
if [[ "$needs_fixing" == true ]] && [[ "$line" =~ ^\[stormux\]$ ]]; then
|
||||||
|
# Skip the [stormux] line and the next lines until we hit an empty line or another section
|
||||||
|
while IFS= read -r skip_line && [[ -n "$skip_line" ]] && [[ ! "$skip_line" =~ ^\[.*\]$ ]]; do
|
||||||
|
continue
|
||||||
|
done
|
||||||
|
# Put back the line we read (if it's a section header)
|
||||||
|
if [[ "$skip_line" =~ ^\[.*\]$ ]]; then
|
||||||
|
line="$skip_line"
|
||||||
|
else
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Add StormUX repo before any AUR or custom repo sections
|
# Add StormUX repo before any AUR or custom repo sections
|
||||||
if [[ "$line" =~ ^\[.*\]$ ]] && [[ ! "$line" =~ ^\[(core|extra|multilib|testing|multilib-testing)\]$ ]] && [[ "$added_repo" == false ]]; then
|
if [[ "$line" =~ ^\[.*\]$ ]] && [[ ! "$line" =~ ^\[(core|extra|multilib|testing|multilib-testing)\]$ ]] && [[ "$added_repo" == false ]]; then
|
||||||
echo "[stormux]" >> "$temp_conf"
|
echo "[stormux]" >> "$temp_conf"
|
||||||
echo "SigLevel = Required" >> "$temp_conf"
|
echo "SigLevel = Required" >> "$temp_conf"
|
||||||
echo "Server = https://aarch64.stormux.org/" >> "$temp_conf"
|
echo "Server = https://aarch64.stormux.org/\$repo-\$arch" >> "$temp_conf"
|
||||||
echo "" >> "$temp_conf"
|
echo "" >> "$temp_conf"
|
||||||
added_repo=true
|
added_repo=true
|
||||||
fi
|
fi
|
||||||
@ -69,7 +90,7 @@ add_stormux_repo() {
|
|||||||
echo "" >> "$temp_conf"
|
echo "" >> "$temp_conf"
|
||||||
echo "[stormux]" >> "$temp_conf"
|
echo "[stormux]" >> "$temp_conf"
|
||||||
echo "SigLevel = Required" >> "$temp_conf"
|
echo "SigLevel = Required" >> "$temp_conf"
|
||||||
echo "Server = https://aarch64.stormux.org/" >> "$temp_conf"
|
echo "Server = https://aarch64.stormux.org/\$repo-\$arch" >> "$temp_conf"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Replace the original pacman.conf
|
# Replace the original pacman.conf
|
||||||
@ -112,18 +133,18 @@ install_xlibre() {
|
|||||||
|
|
||||||
# Install X11Libre packages from StormUX repository
|
# Install X11Libre packages from StormUX repository
|
||||||
infobox "Installing X11Libre server and drivers..."
|
infobox "Installing X11Libre server and drivers..."
|
||||||
if ! sudo "${sudoFlags[@]}" pacman -S --noconfirm xlibre-server-common-git xlibre-server-devel-git; then
|
if ! sudo "${sudoFlags[@]}" pacman -S --noconfirm xlibre-server-common xlibre-server-devel; then
|
||||||
msgbox "Failed to install X11Libre server components."
|
msgbox "Failed to install X11Libre server components."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! sudo "${sudoFlags[@]}" pacman -Sdd --noconfirm xlibre-server-git; then
|
if ! sudo "${sudoFlags[@]}" pacman -Sdd --noconfirm xlibre-server; then
|
||||||
msgbox "Failed to install X11Libre server main package."
|
msgbox "Failed to install X11Libre server main package."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install input and video drivers from StormUX repository
|
# Install input and video drivers from StormUX repository
|
||||||
if ! sudo "${sudoFlags[@]}" pacman -S --noconfirm stormux/xf86-input-libinput-xlibre stormux/xf86-video-dummy-with-vt stormux/xf86-video-fbdev; then
|
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."
|
msgbox "Failed to install X11Libre input and video drivers."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
Reference in New Issue
Block a user