Compare commits
29 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
fffe426d29 | ||
|
45b3c230e1 | ||
|
fa9585a0e1 | ||
|
5e144e7955 | ||
|
e39c1cedec | ||
|
8a7fb83be3 | ||
|
f80ea1e056 | ||
|
696ddd9bfb | ||
|
e0806e51da | ||
|
3612787274 | ||
|
41a0592f20 | ||
|
3ebb6f36cf | ||
|
c88bd17709 | ||
|
c1af07bf18 | ||
|
a88a386ef4 | ||
|
034c561a53 | ||
|
2108f02719 | ||
|
06282f5ea8 | ||
|
6bb5267b91 | ||
|
b87647756f | ||
|
505028ab44 | ||
|
9657719613 | ||
|
3e4c4d18ee | ||
|
9beea608ed | ||
|
69ca3a957c | ||
|
7c62016063 | ||
|
5d43526e85 | ||
|
749ef52656 | ||
|
d0c8b864ae |
@@ -50,9 +50,8 @@ help() {
|
||||
declare -A command=(
|
||||
[h]="This help screen."
|
||||
[l:]="Language default is en_US."
|
||||
[n:]="Image name, default is stormux-pi<32|64>-<yyyy-mm-dd>.img"
|
||||
[s:]="image size in GB, default is 4."
|
||||
[v:]="Version of the Raspberry Pi for which you are building. (32|64) default is 64."
|
||||
[n:]="Image name, default is stormux-pi4-aarch64-<yyyy-mm-dd>.img"
|
||||
[s:]="image size in GB, default is 6."
|
||||
)
|
||||
|
||||
# Convert the keys of the associative array to a format usable by getopts
|
||||
@@ -75,14 +74,6 @@ while getopts "${args}" i ; do
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
v)
|
||||
if [[ "${OPTARG}" =~ ^32|64$ ]]; then
|
||||
imageVersion="${OPTARG}"
|
||||
else
|
||||
echo "Image version must be 32 for 32 bit (armv7h), or 64 for 64 bit (aarch64 default)."
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
exit 1
|
||||
;;
|
||||
@@ -90,11 +81,8 @@ while getopts "${args}" i ; do
|
||||
done
|
||||
|
||||
# make sure variables are set, or use defaults.
|
||||
export imageVersion="${imageVersion:-64}"
|
||||
export imageSize="${imageSize:-6G}"
|
||||
imageName="${imageName:-stormux-pi4-${imageVersion}-$(date '+%Y-%m-%d').img}"
|
||||
imageName="${imageName/-64-/-aarch64-}"
|
||||
imageName="${imageName/-32-/-armv7h-}"
|
||||
imageName="${imageName:-stormux-pi4-aarch64-$(date '+%Y-%m-%d').img}"
|
||||
export imageName
|
||||
export imageLanguage="${imageLanguage:-en_US.UTF-8}"
|
||||
|
||||
@@ -129,85 +117,139 @@ for i in arch-install-scripts dosfstools parted wget ; do
|
||||
done
|
||||
|
||||
|
||||
# Url for the image to be downloaded.
|
||||
url[32]="http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-armv7-latest.tar.gz"
|
||||
url[64]="http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-aarch64-latest.tar.gz"
|
||||
# Url for the aarch64 image to be downloaded.
|
||||
imageUrl="http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-aarch64-latest.tar.gz"
|
||||
|
||||
fallocate -l "$imageSize" "$imageName"
|
||||
loopdev="$(losetup --find --show "${imageName}")"
|
||||
parted --script "${loopdev}" mklabel msdos mkpart primary fat32 0% 200M mkpart primary ext4 200M 100%
|
||||
mkfs.vfat -F32 "${loopdev}p1"
|
||||
mkfs.ext4 -F "${loopdev}p2"
|
||||
mkfs.vfat -F32 -n STRMX_BOOT "${loopdev}p1"
|
||||
mkfs.ext4 -F -L STRMX_ROOT "${loopdev}p2"
|
||||
mount "${loopdev}p2" /mnt
|
||||
mkdir /mnt/boot
|
||||
mount "${loopdev}p1" /mnt/boot
|
||||
# Things are mounted now, so set mounted to 0 (bash true)
|
||||
mounted=0
|
||||
imageFileName=$(mktemp)
|
||||
wget "${url[$imageVersion]}" -O "${imageFileName}"
|
||||
if [[ $imageVersion -eq 32 ]]; then
|
||||
# Workaround for bsdtar errors when extracting 32 bit image.
|
||||
set +e
|
||||
fi
|
||||
wget "${imageUrl}" -O "${imageFileName}"
|
||||
bsdtar -xpf "${imageFileName}" -C /mnt
|
||||
# Set -e in case it got unset for 32 bit image
|
||||
set -e
|
||||
arch-chroot /mnt << EOF
|
||||
|
||||
# Copy override files into place before chroot (except skel to avoid conflicts)
|
||||
cp -rv ../files/boot/* /mnt/boot
|
||||
cp -rv ../files/var/* /mnt/var
|
||||
cp -rv ../files/usr/* /mnt/usr
|
||||
# Copy etc files but exclude skel directory to avoid package conflicts
|
||||
find ../files/etc -mindepth 1 -maxdepth 1 ! -name skel -exec cp -rv {} /mnt/etc/ \;
|
||||
|
||||
PS1="(Chroot) [\u@\h \W] \$" arch-chroot /mnt << EOF
|
||||
echo "Chroot started."
|
||||
# set up pacman
|
||||
pacman-key --init
|
||||
pacman-key --populate archlinuxarm
|
||||
pacman -Syy
|
||||
# Change kernels for aarch64
|
||||
if [[ "$imageVersion" == "64" ]]; then
|
||||
pacman -R --noconfirm linux-aarch64 uboot-raspberrypi
|
||||
pacman -S --noconfirm linux-rpi
|
||||
|
||||
# Add stormux repository
|
||||
echo "Downloading stormux repository key..."
|
||||
curl -s https://packages.stormux.org/stormux_repo.pub > /tmp/stormux_repo.pub
|
||||
echo "Adding key to pacman keyring..."
|
||||
pacman-key --add /tmp/stormux_repo.pub
|
||||
echo "Locally signing key..."
|
||||
pacman-key --lsign-key 52ADA49000F1FF0456F8AEEFB4CDE1CD56EF8E82
|
||||
rm /tmp/stormux_repo.pub
|
||||
# Add repository before core in pacman.conf
|
||||
sed -i '/^\[core\]/i[stormux]\nSigLevel = Required DatabaseOptional\nServer = https://packages.stormux.org/\$arch\n' /etc/pacman.conf
|
||||
|
||||
# Test mirrors and configure based on responsiveness
|
||||
echo "Testing mirror responsiveness..."
|
||||
mirrors=(
|
||||
"mirror.archlinuxarm.org"
|
||||
"fl.us.mirror.archlinuxarm.org"
|
||||
"il.us.mirror.archlinuxarm.org"
|
||||
"tx.us.mirror.archlinuxarm.org"
|
||||
"nj.us.mirror.archlinuxarm.org"
|
||||
)
|
||||
|
||||
working_mirrors=()
|
||||
for mirror in "\${mirrors[@]}"; do
|
||||
echo "Testing \$mirror..."
|
||||
if curl -m 5 -f -s "http://\$mirror/aarch64/core/core.db" > /dev/null 2>&1; then
|
||||
echo " \$mirror: OK"
|
||||
working_mirrors+=("\$mirror")
|
||||
else
|
||||
echo " \$mirror: FAILED"
|
||||
fi
|
||||
done
|
||||
|
||||
# Create mirrorlist with working mirrors first, then fallback to all mirrors
|
||||
> /etc/pacman.d/mirrorlist
|
||||
if [[ \${#working_mirrors[@]} -gt 0 ]]; then
|
||||
echo "Using \${#working_mirrors[@]} working mirrors"
|
||||
for mirror in "\${working_mirrors[@]}"; do
|
||||
echo "Server = http://\$mirror/\\\$arch/\\\$repo" >> /etc/pacman.d/mirrorlist
|
||||
done
|
||||
else
|
||||
echo "No mirrors responded, using all mirrors as fallback"
|
||||
for mirror in "\${mirrors[@]}"; do
|
||||
echo "Server = http://\$mirror/\\\$arch/\\\$repo" >> /etc/pacman.d/mirrorlist
|
||||
done
|
||||
fi
|
||||
|
||||
# Install packages
|
||||
pacman -Su --needed --noconfirm \
|
||||
alsa-firmware \
|
||||
alsa-utils \
|
||||
base \
|
||||
base-devel \
|
||||
bash-completion \
|
||||
bluez \
|
||||
bluez-utils \
|
||||
brltty \
|
||||
cloud-utils \
|
||||
cronie \
|
||||
espeak-ng \
|
||||
fake-hwclock \
|
||||
firmware-raspberrypi \
|
||||
git \
|
||||
go \
|
||||
magic-wormhole \
|
||||
man \
|
||||
man-pages \
|
||||
networkmanager \
|
||||
pipewire \
|
||||
pipewire-alsa \
|
||||
pipewire-jack \
|
||||
pipewire-pulse \
|
||||
poppler \
|
||||
python-pyudev \
|
||||
python-daemonize \
|
||||
python-evdev \
|
||||
python-dbus \
|
||||
python-pyte \
|
||||
raspberrypi-utils \
|
||||
realtime-privileges \
|
||||
rhvoice-voice-bdl \
|
||||
rng-tools \
|
||||
rsync \
|
||||
screen \
|
||||
sox \
|
||||
w3m \
|
||||
wget \
|
||||
wireless-regdb \
|
||||
wireplumber \
|
||||
xdg-user-dirs \
|
||||
xdg-utils
|
||||
pacman -Syy
|
||||
# Change to the Pi kernel for aarch64
|
||||
pacman -R --noconfirm linux-aarch64 uboot-raspberrypi
|
||||
pacman -S --noconfirm linux-rpi
|
||||
|
||||
# Install all packages (stormux repo has priority since it's listed first)
|
||||
packages=(
|
||||
alsa-firmware
|
||||
alsa-utils
|
||||
base
|
||||
base-devel
|
||||
bash-completion
|
||||
bluez
|
||||
bluez-utils
|
||||
brltty
|
||||
cronie
|
||||
espeak-ng
|
||||
fake-hwclock
|
||||
fenrir
|
||||
firmware-raspberrypi
|
||||
git
|
||||
magic-wormhole
|
||||
man
|
||||
man-pages
|
||||
networkmanager
|
||||
parted
|
||||
pipewire
|
||||
pipewire-alsa
|
||||
pipewire-jack
|
||||
pipewire-pulse
|
||||
poppler
|
||||
python-dbus
|
||||
python-pyenchant
|
||||
python-pyte
|
||||
python-setuptools-scm
|
||||
python-pyperclip
|
||||
raspberrypi-utils
|
||||
socat
|
||||
realtime-privileges
|
||||
rhvoice-voice-bdl
|
||||
rng-tools
|
||||
rsync
|
||||
screen
|
||||
sox
|
||||
w3m-git
|
||||
wget
|
||||
wireless-regdb
|
||||
wireplumber
|
||||
xdg-user-dirs
|
||||
xdg-utils
|
||||
yay
|
||||
)
|
||||
|
||||
pacman -Su --needed --noconfirm "\${packages[@]}"
|
||||
|
||||
# Restart gpg agents.
|
||||
gpgconf --kill all
|
||||
# set the language
|
||||
sed -i "s/#$imageLanguage/$imageLanguage/" /etc/locale.gen
|
||||
echo "LANG=$imageLanguage" > /etc/locale.conf
|
||||
@@ -226,29 +268,14 @@ echo 'stormux ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers.d/wheel
|
||||
echo -e "root\nroot" | passwd "root"
|
||||
# Set the password for the stormux user
|
||||
echo -e "stormux\nstormux" | passwd "stormux"
|
||||
# Change to the stormux user and install some packages
|
||||
|
||||
# Change to the stormux user for user configuration
|
||||
sudo -iu stormux
|
||||
# suppress git spam about default branch name
|
||||
git config --global init.defaultBranch master
|
||||
# Create desktop, downloads, music, and other directories.
|
||||
xdg-user-dirs-update
|
||||
# Build AUR packages
|
||||
export aurPackages=(fenrir-git \
|
||||
growpartfs \
|
||||
log2ram \
|
||||
yay)
|
||||
export PKGDEST=~/packages
|
||||
for p in "\${aurPackages[@]}" ; do
|
||||
git clone https://aur.archlinux.org/\${p}.git
|
||||
cd ~/\${p}
|
||||
makepkg -A
|
||||
cd ~
|
||||
rm -rf \${p}
|
||||
done
|
||||
exit
|
||||
# Install built packages
|
||||
for p in /home/stormux/packages/* ; do
|
||||
pacman -U --noconfirm \${p}
|
||||
done
|
||||
rm -rf /home/stormux/packages/
|
||||
# Enable linger so that hopefully sound will start at login.
|
||||
mkdir -p /var/lib/systemd/linger
|
||||
touch /var/lib/systemd/linger/stormux
|
||||
@@ -261,20 +288,32 @@ echo '%wheel ALL=(ALL) ALL' > /etc/sudoers.d/wheel
|
||||
echo stormux > /etc/hostname
|
||||
# Configure services
|
||||
systemctl disable systemd-networkd.service systemd-networkd.socket
|
||||
systemctl enable brltty.path cronie.service fake-hwclock.service fenrirscreenreader.service log2ram.service NetworkManager.service
|
||||
# Enable services
|
||||
services=(
|
||||
brltty.path
|
||||
cronie.service
|
||||
fake-hwclock.service
|
||||
fenrirscreenreader.service
|
||||
log-to-ram-setup.service
|
||||
log-to-ram-sync.timer
|
||||
log-to-ram-shutdown.service
|
||||
NetworkManager.service
|
||||
)
|
||||
|
||||
for service in "\${services[@]}"; do
|
||||
echo "Enabling \$service..."
|
||||
if systemctl enable "\$service"; then
|
||||
echo " \$service: OK"
|
||||
else
|
||||
echo " \$service: FAILED"
|
||||
fi
|
||||
done
|
||||
# Cleanup packages
|
||||
pacman -Sc --noconfirm
|
||||
pacman -R --noconfirm go
|
||||
|
||||
# Update fstab for Raspberry Pi 4. Not needed until linux-aarch64 works.
|
||||
# [[ $imageVersion -eq 4 ]] && sed -i 's/mmcblk0/mmcblk1/g' /etc/fstab
|
||||
EOF
|
||||
|
||||
# Copy override files into place.
|
||||
cp -rv ../files/boot/* /mnt/boot
|
||||
cp -rv ../files/etc/* /mnt/etc
|
||||
cp -rv ../files/var/* /mnt/var
|
||||
cp -rv ../files/usr/* /mnt/usr
|
||||
# Copy skel files to stormux user home (after user rename in chroot)
|
||||
find ../files/etc/skel/ -mindepth 1 -exec cp -rv "{}" /mnt/home/stormux/ \;
|
||||
|
||||
# Exiting calls the cleanup function to unmount.
|
||||
|
1
pi4/files/boot/cmdline.txt
Normal file
1
pi4/files/boot/cmdline.txt
Normal file
@@ -0,0 +1 @@
|
||||
root=LABEL=STRMX_ROOT rw rootwait console=serial0,115200 console=tty1 fsck.repair=yes
|
@@ -1,32 +0,0 @@
|
||||
Section "ServerLayout"
|
||||
Identifier "Layout0"
|
||||
Screen 0 "Screen0"
|
||||
EndSection
|
||||
|
||||
Section "Monitor"
|
||||
Identifier "Monitor0"
|
||||
Option "DPMS" "true"
|
||||
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 "Card0"
|
||||
# Try standard driver
|
||||
Driver "modesetting"
|
||||
# Fallback to dummy
|
||||
Option "FallbackDriver" "dummy"
|
||||
VideoRam 256000
|
||||
EndSection
|
||||
|
||||
Section "Screen"
|
||||
Identifier "Screen0"
|
||||
Device "Card0"
|
||||
Monitor "Monitor0"
|
||||
DefaultDepth 24
|
||||
SubSection "Display"
|
||||
Depth 24
|
||||
Modes "1920x1080"
|
||||
EndSubSection
|
||||
EndSection
|
7
pi4/files/etc/fstab
Normal file
7
pi4/files/etc/fstab
Normal file
@@ -0,0 +1,7 @@
|
||||
# Static information about the filesystems.
|
||||
# See fstab(5) for details.
|
||||
|
||||
# <file system> <dir> <type> <options> <dump> <pass>
|
||||
LABEL=STRMX_BOOT /boot vfat defaults 0 1
|
||||
LABEL=STRMX_ROOT / ext4 defaults,noatime 0 1
|
||||
tmpfs /var/log tmpfs defaults,noatime,nosuid,nodev,noexec,mode=0755,size=128M 0 0
|
@@ -1,37 +0,0 @@
|
||||
# Configuration file for Log2Ram (https://github.com/azlux/log2ram) under MIT license.
|
||||
# This configuration file is read by the log2ram service
|
||||
|
||||
# Size for the ram folder, it defines the size the log folder will reserve into the RAM.
|
||||
# If it's not enough, log2ram will not be able to use ram. Check you /var/log size folder.
|
||||
# The default is 40M and is basically enough for a lot of applications.
|
||||
# You will need to increase it if you have a server and a lot of log for example.
|
||||
SIZE=128M
|
||||
|
||||
# This variable can be set to true if you prefer "rsync" rather than "cp".
|
||||
# I use the command cp -u and rsync -X, so I don't copy the all folder every time for optimization.
|
||||
# You can choose which one you want. Be sure rsync is installed if you use it.
|
||||
USE_RSYNC=true
|
||||
|
||||
# If there are some errors with available RAM space, a system mail will be send
|
||||
# Change it to false and you will have only a log if there is no place on RAM anymore.
|
||||
MAIL=false
|
||||
|
||||
# Variable for folders to put in RAM. You need to specify the real folder `/path/folder` , the `/path/hdd.folder` will be automatically created. Multiple path can be separeted by `;`. Do not add the final `/` !
|
||||
# example : PATH_DISK="/var/log;/home/test/FolderInRam"
|
||||
PATH_DISK="/var/log"
|
||||
|
||||
# **************** Zram backing conf *************************************************
|
||||
|
||||
# ZL2R Zram Log 2 Ram enables a zram drive when ZL2R=true ZL2R=false is mem only tmpfs
|
||||
ZL2R=false
|
||||
# COMP_ALG this is any compression algorithm listed in /proc/crypto
|
||||
# lz4 is fastest with lightest load but deflate (zlib) and Zstandard (zstd) give far better compression ratios
|
||||
# lzo is very close to lz4 and may with some binaries have better optimisation
|
||||
# COMP_ALG=lz4 for speed or Zstd for compression, lzo or zlib if optimisation or availabilty is a problem
|
||||
COMP_ALG=lz4
|
||||
# LOG_DISK_SIZE is the uncompressed disk size. Note zram uses about 0.1% of the size of the disk when not in use
|
||||
# LOG_DISK_SIZE is expected compression ratio of alg chosen multiplied by log SIZE
|
||||
# lzo/lz4=2.1:1 compression ratio zlib=2.7:1 zstandard=2.9:1
|
||||
# Really a guestimate of a bit bigger than compression ratio whilst minimising 0.1% mem usage of disk size
|
||||
LOG_DISK_SIZE=100M
|
||||
|
1
pi4/files/etc/modprobe.d/brcmfmac.conf
Normal file
1
pi4/files/etc/modprobe.d/brcmfmac.conf
Normal file
@@ -0,0 +1 @@
|
||||
options brcmfmac feature_disable=0x82000
|
@@ -1,6 +0,0 @@
|
||||
#%PAM-1.0
|
||||
|
||||
auth include system-local-login
|
||||
account include system-local-login
|
||||
password include system-local-login
|
||||
session include system-local-login
|
@@ -12,6 +12,34 @@ if ! [[ -x /usr/local/bin/configure-stormux ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
# Volume calibration FIRST
|
||||
echo "Setting up audio volume..."
|
||||
volume=50
|
||||
wait=0
|
||||
|
||||
# Wait for pipewire to become available
|
||||
while [[ $wait -lt 30 ]]; do
|
||||
if pgrep pipewire &> /dev/null ; then
|
||||
break
|
||||
else
|
||||
sleep 1
|
||||
((wait++))
|
||||
fi
|
||||
done
|
||||
|
||||
# Volume calibration - this should be the VERY FIRST interactive part
|
||||
while [[ $volume -le 130 ]]; do
|
||||
clear
|
||||
pactl set-sink-volume @DEFAULT_SINK@ "${volume}%" 2>/dev/null
|
||||
spd-say "If this is loud enough, press enter."
|
||||
if read -t4 ; then
|
||||
echo "Volume set to ${volume}%"
|
||||
break
|
||||
else
|
||||
((volume+=5))
|
||||
fi
|
||||
done
|
||||
|
||||
# For audible sudo prompts:
|
||||
unset sudoFlags
|
||||
if [[ -x /etc/audibleprompt.sh ]]; then
|
||||
@@ -19,6 +47,7 @@ if [[ -x /etc/audibleprompt.sh ]]; then
|
||||
export sudoFlags=("-A")
|
||||
fi
|
||||
|
||||
clear
|
||||
cat << "EOF"
|
||||
Hello, and welcome to Stormux!
|
||||
|
||||
|
@@ -1,47 +0,0 @@
|
||||
# This file is part of systemd.
|
||||
#
|
||||
# systemd is free software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU Lesser General Public License as published by the Free
|
||||
# Software Foundation; either version 2.1 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# Entries in this file show the compile time defaults. Local configuration
|
||||
# should be created by either modifying this file, or by creating "drop-ins" in
|
||||
# the journald.conf.d/ subdirectory. The latter is generally recommended.
|
||||
# Defaults can be restored by simply deleting this file and all drop-ins.
|
||||
#
|
||||
# Use 'systemd-analyze cat-config systemd/journald.conf' to display the full config.
|
||||
#
|
||||
# See journald.conf(5) for details.
|
||||
|
||||
[Journal]
|
||||
#Storage=auto
|
||||
#Compress=yes
|
||||
#Seal=yes
|
||||
#SplitMode=uid
|
||||
#SyncIntervalSec=5m
|
||||
#RateLimitIntervalSec=30s
|
||||
#RateLimitBurst=10000
|
||||
SystemMaxUse=20M
|
||||
#SystemKeepFree=
|
||||
#SystemMaxFileSize=
|
||||
#SystemMaxFiles=100
|
||||
#RuntimeMaxUse=
|
||||
#RuntimeKeepFree=
|
||||
#RuntimeMaxFileSize=
|
||||
#RuntimeMaxFiles=100
|
||||
#MaxRetentionSec=
|
||||
#MaxFileSec=1month
|
||||
#ForwardToSyslog=no
|
||||
#ForwardToKMsg=no
|
||||
#ForwardToConsole=no
|
||||
#ForwardToWall=yes
|
||||
#TTYPath=/dev/console
|
||||
#MaxLevelStore=debug
|
||||
#MaxLevelSyslog=debug
|
||||
#MaxLevelKMsg=notice
|
||||
#MaxLevelConsole=info
|
||||
#MaxLevelWall=emerg
|
||||
#LineMax=48K
|
||||
#ReadKMsg=yes
|
||||
#Audit=yes
|
3
pi4/files/etc/systemd/journald.conf.d/99-ramlog.conf
Normal file
3
pi4/files/etc/systemd/journald.conf.d/99-ramlog.conf
Normal file
@@ -0,0 +1,3 @@
|
||||
[Journal]
|
||||
Storage=volatile
|
||||
SystemMaxUse=20M
|
16
pi4/files/etc/systemd/system/log-to-ram-setup.service
Normal file
16
pi4/files/etc/systemd/system/log-to-ram-setup.service
Normal file
@@ -0,0 +1,16 @@
|
||||
[Unit]
|
||||
Description=Setup RAM logging and restore logs from disk
|
||||
DefaultDependencies=false
|
||||
After=local-fs.target
|
||||
Before=sysinit.target
|
||||
RequiresMountsFor=/var
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
ExecStartPre=/bin/mkdir -p /var/log.hdd
|
||||
ExecStartPre=/bin/sh -c 'if [ -d /var/log.hdd ] && [ "$(ls -A /var/log.hdd 2>/dev/null)" ]; then cp -au /var/log.hdd/* /var/log/ 2>/dev/null || true; fi'
|
||||
ExecStart=/bin/true
|
||||
|
||||
[Install]
|
||||
WantedBy=sysinit.target
|
14
pi4/files/etc/systemd/system/log-to-ram-shutdown.service
Normal file
14
pi4/files/etc/systemd/system/log-to-ram-shutdown.service
Normal file
@@ -0,0 +1,14 @@
|
||||
[Unit]
|
||||
Description=Sync logs to disk before shutdown
|
||||
DefaultDependencies=false
|
||||
Before=shutdown.target reboot.target halt.target
|
||||
Conflicts=shutdown.target reboot.target halt.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=true
|
||||
ExecStart=/bin/sh -c 'rsync -aXv --delete --exclude="*.hdd" /var/log/ /var/log.hdd/ 2>/dev/null || true'
|
||||
TimeoutStopSec=30
|
||||
|
||||
[Install]
|
||||
WantedBy=shutdown.target reboot.target halt.target
|
8
pi4/files/etc/systemd/system/log-to-ram-sync.service
Normal file
8
pi4/files/etc/systemd/system/log-to-ram-sync.service
Normal file
@@ -0,0 +1,8 @@
|
||||
[Unit]
|
||||
Description=Sync logs from RAM to disk
|
||||
After=local-fs.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStartPre=/bin/mkdir -p /var/log.hdd
|
||||
ExecStart=/bin/sh -c 'rsync -aXv --delete --exclude="*.hdd" /var/log/ /var/log.hdd/ 2>/dev/null || true'
|
11
pi4/files/etc/systemd/system/log-to-ram-sync.timer
Normal file
11
pi4/files/etc/systemd/system/log-to-ram-sync.timer
Normal file
@@ -0,0 +1,11 @@
|
||||
[Unit]
|
||||
Description=Sync logs from RAM to disk every hour
|
||||
Requires=log-to-ram-sync.service
|
||||
|
||||
[Timer]
|
||||
OnBootSec=15min
|
||||
OnUnitActiveSec=1h
|
||||
Persistent=true
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
3
pi4/files/etc/vconsole.conf
Normal file
3
pi4/files/etc/vconsole.conf
Normal file
@@ -0,0 +1,3 @@
|
||||
# This is the fallback vconsole configuration provided by systemd.
|
||||
|
||||
KEYMAP=us_alt
|
103
pi4/files/root/rename-user.sh
Executable file
103
pi4/files/root/rename-user.sh
Executable file
@@ -0,0 +1,103 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Renames a user
|
||||
# Required arguments: old user name, new user name
|
||||
|
||||
set -e
|
||||
|
||||
question() {
|
||||
echo
|
||||
echo "$@"
|
||||
read -r answer
|
||||
answer="${answer:0:1}"
|
||||
answer="${answer^}"
|
||||
}
|
||||
|
||||
if [[ $# -ne 2 ]]; then
|
||||
echo "Usage: $0 old-user new-user"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
oldUser="$1"
|
||||
newUser="$2"
|
||||
|
||||
# Make sure old user exists
|
||||
if ! id "$oldUser" >/dev/null 2>&1; then
|
||||
echo "The user $oldUser does not exist."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Make sure old user is not logged in
|
||||
if pgrep -u "$oldUser" >/dev/null; then
|
||||
echo "The user $oldUser is currently logged in or has running processes. Cannot continue."
|
||||
question "Would you like to forcibly log out $oldUser? (Y/N)"
|
||||
if [[ "$answer" != "Y" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
systemctl stop display-manager
|
||||
loginctl terminate-user "$oldUser"
|
||||
sleep 2
|
||||
if pgrep -u "$oldUser" >/dev/null; then
|
||||
echo "The user $oldUser still has running processes after termination. Cannot continue."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Make sure new user does not exist
|
||||
if id "$newUser" >/dev/null 2>&1; then
|
||||
echo "The user name $newUser is already taken."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Make sure the new name is acceptable
|
||||
if ! [[ "$newUser" =~ ^[a-z_][a-z0-9_-]{0,31}$ ]]; then
|
||||
echo "$newUser is not an acceptable user name."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Passed all safety checks, proceed with the rename
|
||||
echo "Renaming $oldUser to $newUser..."
|
||||
groups=$(id -nG "$oldUser")
|
||||
groups="${groups// /,}"
|
||||
usermod -G "$groups" -m -d "/home/$newUser" -l "$newUser" "$oldUser"
|
||||
|
||||
# Update nodm.conf if it exists
|
||||
if [[ -e /etc/nodm.conf ]]; then
|
||||
echo "Updating /etc/nodm.conf..."
|
||||
sed -i -e "s#^NODM_USER=.*#NODM_USER='$newUser'#" -e "s#^NODM_XSESSION=.*#NODM_XSESSION='/home/$newUser/.xinitrc'#" /etc/nodm.conf
|
||||
fi
|
||||
|
||||
# Copy over crontab if it exists
|
||||
if crontab -u "$oldUser" -l >/tmp/${oldUser}_crontab.bak 2>/dev/null; then
|
||||
echo "Copying over crontab..."
|
||||
if crontab -u "$newUser" "/tmp/${oldUser}_crontab.bak"; then
|
||||
rm "/tmp/${oldUser}_crontab.bak"
|
||||
else
|
||||
echo "Warning: failed to restore crontab for $newUser."
|
||||
rm "/tmp/${oldUser}_crontab.bak"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Update linger
|
||||
if [[ -e "/var/lib/systemd/linger/$oldUser" ]]; then
|
||||
echo "Enabling linger..."
|
||||
mv "/var/lib/systemd/linger/$oldUser" "/var/lib/systemd/linger/$newUser"
|
||||
fi
|
||||
|
||||
# Optionally update files in new home directory
|
||||
echo
|
||||
echo "Would you like to search for references to $oldUser and update them to $newUser in files located in /home/$newUser?"
|
||||
question "This can take a while. (Y/N)"
|
||||
if [[ "$answer" == "Y" ]]; then
|
||||
echo "Updating files..."
|
||||
find "/home/$newUser" -type f -exec grep -Iq . "{}" \; -and -exec sed -i "s|$oldUser|$newUser|g" "{}" \;
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "Rename complete. The user, $newUser, is now available."
|
||||
question "Would you like to reboot?"
|
||||
if [[ "${answer}" == "Y" ]]; then
|
||||
reboot
|
||||
fi
|
||||
|
||||
exit 0
|
@@ -24,6 +24,8 @@ if [[ -x /opt/configure-stormux/configure-stormux.sh ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Volume calibration is now handled in stormux_first_boot.sh
|
||||
|
||||
export DIALOGOPTS='--insecure --no-lines --visit-items'
|
||||
|
||||
set_timezone() {
|
||||
@@ -52,8 +54,6 @@ set_timezone() {
|
||||
ln -sf /usr/share/zoneinfo/${region}/${city} /etc/localtime
|
||||
timedatectl set-ntp true
|
||||
}
|
||||
|
||||
|
||||
# Offer to switch fenrir layout.
|
||||
echo "Would you like to switch Fenrir to laptop layout?"
|
||||
echo "Press y for yes or n for no followed by enter."
|
||||
@@ -75,23 +75,25 @@ if [[ $diskSize -le 7 ]]; then
|
||||
read -r continue
|
||||
continue="${continue::1}"
|
||||
if [[ "${continue,}" == "y" ]];then
|
||||
sudo "${sudoFlags[@]}" growpartfs $diskSource
|
||||
# Extract base device name (handles mmcblk0p2, nvme0n1p2, sda2, etc.)
|
||||
if [[ "$diskSource" =~ (.*[0-9]+)p[0-9]+$ ]]; then
|
||||
# Handle mmcblk0p2, nvme0n1p2 style
|
||||
diskDevice="${BASH_REMATCH[1]}"
|
||||
else
|
||||
# Handle sda2, sdb3 style
|
||||
diskDevice="$(echo "$diskSource" | sed 's/[0-9]*$//')"
|
||||
fi
|
||||
echo "Yes" | sudo "${sudoFlags[@]}" parted ---pretend-input-tty "$diskDevice" resizepart 2 100%
|
||||
sudo "${sudoFlags[@]}" resize2fs -f "$diskSource"
|
||||
fi
|
||||
fi
|
||||
|
||||
if ! ping -c1 stormux.org &> /dev/null ; then
|
||||
echo "No internet connection detected. Press enter to open NetworkManager."
|
||||
echo "Note, it is best to put Fenrir into highlight mode while using NetworkManager."
|
||||
echo "In desktop layout this is done by pressing Fenrir+numpad asterisk."
|
||||
echo "That is the key just above numpad 9."
|
||||
echo "In laptop mode, press Fenrir+y."
|
||||
echo "In desktop mode the Fenrir key is numpad insert."
|
||||
echo "In laptop mode the Fenrir key is the Super key, sometimes called the Windows key."
|
||||
echo "After connecting to the internet, remember to go back to cursor mode."
|
||||
echo "It is the same key used to switch to highlight mode."
|
||||
echo "Press enter to continue."
|
||||
read -r continue
|
||||
echo "setting set focus#highlight=True" | socat - UNIX-CLIENT:/tmp/fenrirscreenreader-deamon.sock
|
||||
nmtui-connect
|
||||
echo "setting set focus#highlight=False" | socat - UNIX-CLIENT:/tmp/fenrirscreenreader-deamon.sock
|
||||
fi
|
||||
# Check for internet connectivity
|
||||
if ping -qc1 -W 1 stormux.org &> /dev/null; then
|
||||
|
BIN
pi4/files/usr/share/kbd/keymaps/i386/qwerty/us_alt.map.gz
Normal file
BIN
pi4/files/usr/share/kbd/keymaps/i386/qwerty/us_alt.map.gz
Normal file
Binary file not shown.
Reference in New Issue
Block a user