Build optimization: pre-built PM3 binaries, ARM64 CI, base image caching
Replace PM3 compile-from-source in pi-gen with pre-built tarball extraction (saves 43-58 min). Merge stagePM3 into stageDangerousPi as 02-pm3-install substage, renumber all subsequent substages. Switch CI PM3 build to native ARM64 runner (ubuntu-24.04-arm64) eliminating QEMU overhead. Add weekly base-image workflow for pre-baking stages 0-2. Support PM3_TARBALL, BASE_IMAGE, and APT_PROXY env vars in build-image.sh. Also includes prior Phase 5 work: theme system, design system integration, component update system, OS updates, CI build pipeline, and test results. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
86
pi-gen/stageDangerousPi/03-ttyd/00-run-chroot.sh
Normal file
86
pi-gen/stageDangerousPi/03-ttyd/00-run-chroot.sh
Normal file
@@ -0,0 +1,86 @@
|
||||
#!/bin/bash -e
|
||||
|
||||
cd /usr/local/bin
|
||||
|
||||
for i in aarch64 arm armhf
|
||||
do
|
||||
wget https://github.com/tsl0922/ttyd/releases/download/1.7.7/ttyd.${i}
|
||||
done
|
||||
|
||||
case `uname -m` in
|
||||
"armv7l") model=armhf ;;
|
||||
"aarch64") model=aarch64 ;;
|
||||
*) model=arm ;;
|
||||
esac
|
||||
|
||||
cp ttyd.${model} /usr/local/bin/ttyd
|
||||
chown root:root /usr/local/bin/ttyd
|
||||
chmod a+x /usr/local/bin/ttyd
|
||||
|
||||
# Detect the default user (cloud-init compatible)
|
||||
# Find first user with UID >= 1000 (excluding nobody)
|
||||
DEFAULT_USER=$(awk -F: '$3 >= 1000 && $3 < 65534 {print $1; exit}' /etc/passwd)
|
||||
if [ -z "$DEFAULT_USER" ]; then
|
||||
DEFAULT_USER="pi" # Fallback to pi if detection fails
|
||||
fi
|
||||
DEFAULT_HOME=$(eval echo ~$DEFAULT_USER)
|
||||
|
||||
echo "Detected default user: $DEFAULT_USER (home: $DEFAULT_HOME)"
|
||||
|
||||
USER_UID=$(id -u $DEFAULT_USER)
|
||||
|
||||
cat > /etc/systemd/system/ttyd-bash.service << EOF
|
||||
[Unit]
|
||||
Description=Web Terminal Service running Bash
|
||||
After=network.target
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
||||
[Service]
|
||||
User=$DEFAULT_USER
|
||||
WorkingDirectory=$DEFAULT_HOME
|
||||
ExecStart=/usr/local/bin/ttyd -p 8000 -W -u $USER_UID -m 1 -c $DEFAULT_USER:proxmark3 /usr/bin/bash
|
||||
Restart=always
|
||||
Type=simple
|
||||
RestartSec=1
|
||||
|
||||
EOF
|
||||
|
||||
cat > /etc/systemd/system/ttyd-pm3.service << EOF
|
||||
[Unit]
|
||||
Description=Web Terminal Service for PM3
|
||||
After=network.target
|
||||
ConditionFileIsExecutable=/usr/local/bin/pm3
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
||||
[Service]
|
||||
User=$DEFAULT_USER
|
||||
WorkingDirectory=$DEFAULT_HOME
|
||||
ExecStart=/usr/local/bin/ttyd -p 8080 -W -u $USER_UID -m 1 /usr/local/bin/pm3
|
||||
Restart=always
|
||||
Type=simple
|
||||
RestartSec=1
|
||||
|
||||
EOF
|
||||
|
||||
chmod 755 /etc/systemd/system/ttyd*.service
|
||||
chown root:root /etc/systemd/system/ttyd*.service
|
||||
|
||||
if [ ! -L /etc/systemd/system/multi-user.target.wants/ttyd-bash.service ]
|
||||
then
|
||||
ln -s /etc/systemd/system/ttyd-bash.service /etc/systemd/system/multi-user.target.wants
|
||||
fi
|
||||
|
||||
if [ ! -L /etc/systemd/system/multi-user.target.wants/ttyd-pm3.service ]
|
||||
then
|
||||
ln -s /etc/systemd/system/ttyd-pm3.service /etc/systemd/system/multi-user.target.wants
|
||||
fi
|
||||
|
||||
# PM3 is now installed to user's home/.pm3/proxmark3/ instead of make install
|
||||
# Create symlink for backwards compatibility if needed
|
||||
if [ ! -f /usr/local/bin/pm3 ] && [ -f $DEFAULT_HOME/.pm3/proxmark3/client/proxmark3 ]; then
|
||||
ln -s $DEFAULT_HOME/.pm3/proxmark3/client/proxmark3 /usr/local/bin/pm3
|
||||
fi
|
||||
Reference in New Issue
Block a user