mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-10-26 19:01:39 -04:00
Creating script which runs on first startup only. This is used to copy /etc/skel files to first user's home directory.
This commit is contained in:
parent
e18b1b0552
commit
336ef1abb4
3 changed files with 33 additions and 2 deletions
12
etc/raspberrypios/wrolpi-first-startup.service
Normal file
12
etc/raspberrypios/wrolpi-first-startup.service
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
[Unit]
|
||||
Description=Run script at first startup
|
||||
After=multi-user.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/opt/wrolpi/wrolpi/scripts/first_startup.sh
|
||||
RemainAfterExit=true
|
||||
StandardOutput=journal
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
|
@ -12,9 +12,7 @@ alias la='ll -a'
|
|||
EOF
|
||||
|
||||
# Create WROLPi user. This user will own the media directory, API, and App.
|
||||
# The `pi` user will be the maintainer's user.
|
||||
useradd -md /home/wrolpi wrolpi -s "$(command -v bash)"
|
||||
usermod -aG pi wrolpi
|
||||
|
||||
# Change default postgresql port to 5432.
|
||||
sed -i 's/port = 5433/port = 5432/' /etc/postgresql/15/main/postgresql.conf
|
||||
|
|
@ -50,6 +48,8 @@ chown wrolpi:wrolpi /media/wrolpi
|
|||
|
||||
cp /opt/wrolpi/etc/raspberrypios/wrolpi-*.service /etc/systemd/system/
|
||||
cp /opt/wrolpi/etc/raspberrypios/wrolpi.target /etc/systemd/system/
|
||||
# Enable first startup script.
|
||||
systemctl enable wrolpi-first-startup.service
|
||||
|
||||
# NetworkManager for the hotspot.
|
||||
systemctl enable NetworkManager
|
||||
|
|
|
|||
19
wrolpi/scripts/first_startup.sh
Executable file
19
wrolpi/scripts/first_startup.sh
Executable file
|
|
@ -0,0 +1,19 @@
|
|||
#!/usr/bin/env bash
|
||||
# This script is run once on the first startup of a Raspberry Pi.
|
||||
|
||||
# Copy skeleton files to first users home directory.
|
||||
USER_HOME=$(getent passwd 1000 | cut -d: -f6)
|
||||
if [ "$(ls -A /etc/skel)" ]; then
|
||||
echo "Files found in /etc/skel, copying to $USER_HOME..."
|
||||
# Copy files from /etc/skel to the user's home directory
|
||||
cp -r /etc/skel/. "$USER_HOME"
|
||||
# Change ownership to the user with UID 1000
|
||||
chown -R 1000:1000 "$USER_HOME"
|
||||
echo "Files copied successfully."
|
||||
else
|
||||
echo "No files found in /etc/skel."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Do not run this script again.
|
||||
systemctl disable wrolpi-first-startup.service
|
||||
Loading…
Add table
Add a link
Reference in a new issue