Changing RPi first user to pi.

This commit is contained in:
Roland 2023-05-18 17:25:22 -06:00
parent ac06a9b8b2
commit 4f4009f232
No known key found for this signature in database
GPG key ID: 9D6DBD3ACF11AB93
3 changed files with 24 additions and 9 deletions

View file

@ -5,7 +5,7 @@ LOCALE_DEFAULT=en_US.UTF-8
TARGET_HOSTNAME=wrolpi
KEYBOARD_KEYMAP=en_US
KEYBOARD_LAYOUT="English (US)"
FIRST_USER_NAME=wrolpi
FIRST_USER_NAME=pi
FIRST_USER_PASS=wrolpi
DISABLE_FIRST_BOOT_USER_RENAME=1
ENABLE_SSH=1

View file

@ -11,6 +11,10 @@ alias ll='ls -lh'
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.
grep wrolpi: /etc/passwd || useradd -md /home/wrolpi wrolpi -s "$(command -v bash)"
# Change default postgresql port to 5432.
sed -i 's/port = 5433/port = 5432/' /etc/postgresql/13/main/postgresql.conf
@ -31,7 +35,7 @@ cd /opt/wrolpi/app
npm install
npm run build
chown -R ${FIRST_USER_NAME}:${FIRST_USER_NAME} /opt/wrolpi
chown -R wrolpi:wrolpi /opt/wrolpi
# Configure nginx.
cp /opt/wrolpi/nginx.conf /etc/nginx/nginx.conf
@ -53,7 +57,7 @@ EOF
chmod 660 /etc/sudoers.d/90-wrolpi
[ -d /media/wrolpi ] || mkdir /media/wrolpi
chown ${FIRST_USER_NAME}:${FIRST_USER_NAME} /media/wrolpi
chown wrolpi:wrolpi /media/wrolpi
cp /opt/wrolpi/etc/raspberrypios/wrolpi-api.service /etc/systemd/system/
cp /opt/wrolpi/etc/raspberrypios/wrolpi-app.service /etc/systemd/system/

View file

@ -8,27 +8,28 @@ if [ ! -d /opt/openstreetmap-carto ]; then
git clone https://github.com/lrnselfreliance/openstreetmap-carto.git /opt/openstreetmap-carto
fi
(cd /opt/openstreetmap-carto && git fetch && git checkout master && git reset --hard origin/master && git pull --ff)
chown -R ${FIRST_USER_NAME}:${FIRST_USER_NAME} /opt/openstreetmap-carto
chown -R wrolpi:wrolpi /opt/openstreetmap-carto
cd /opt/openstreetmap-carto
if [[ ! -f /opt/openstreetmap-carto/mapnik.xml || ! -s /opt/openstreetmap-carto/mapnik.xml ]]; then
/usr/bin/carto project.mml >/opt/openstreetmap-carto/mapnik.xml
fi
# WROLPi user can access WROLPi and Map database.
cat >/home/wrolpi/.pgpass <<'EOF'
cat >/home/pi/.pgpass <<'EOF'
127.0.0.1:5432:gis:_renderd:wrolpi
127.0.0.1:5432:wrolpi:wrolpi:wrolpi
EOF
cat >/home/wrolpi/wrolpi.desktop <<'EOF'
cat >/home/pi/Deskop/wrolpi.desktop <<'EOF'
[Desktop Entry]
Encoding=UTF-8
Name=WROLPi App
Type=Link
URL=http://locahost
URL=http://127.0.0.1
Icon=/opt/wrolpi/icon.png
EOF
chown -R ${FIRST_USER_NAME}:${FIRST_USER_NAME} /home/wrolpi
chmod 0600 /home/wrolpi/.pgpass
chown -R pi:pi /home/pi
chmod 0600 /home/pi/.pgpass
usermod -aG wrolpi pi
# Configure renderd.
cp /opt/wrolpi/etc/raspberrypios/renderd.conf /etc/renderd.conf
@ -48,6 +49,16 @@ usermod -aG _renderd wrolpi
[ -d /var/cache/renderd/tiles ] || mkdir /var/cache/renderd/tiles
chown -R _renderd:_renderd /var/cache/renderd/tiles
# Create the media directory for the wrolpi user.
echo '/dev/sda1 /media/wrolpi auto defaults,nofail 0 0' | tee -a /etc/fstab
mkdir -p /media/wrolpi
cat >/home/wrolpi/.pgpass <<'EOF'
127.0.0.1:5432:gis:_renderd:wrolpi
127.0.0.1:5432:wrolpi:wrolpi:wrolpi
EOF
chmod 0600 /home/wrolpi/.pgpass
chown -R wrolpi:wrolpi /media/wrolpi /home/wrolpi
set +x
echo