Last active
December 31, 2023 18:54
-
-
Save valentino-sm/701bbb077b17a7f1e4171d8d4e6c24bc to your computer and use it in GitHub Desktop.
The script for quick setup PostmarketOS for Docker.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/ash | |
# | |
# The script for quick setup PostmarketOS for Docker. | |
# We need internet connection only. | |
# | |
# Install from sudo like: | |
# $> wget -O - <SCRIPT_URL> | sudo ash | |
if [[ $(id -u) -ne 0 || -z "$SUDO_USER" ]] ; then echo "Please run from sudo" ; exit 1 ; fi | |
TARGET_USER=${SUDO_USER} | |
# Check internet connection. Restart NetworkManager if failed | |
if ! wget -q --spider http://google.com; then | |
echo "No internet connection, trying to setup..." | |
rc-service networkmanager restart | |
nmtui | |
while ! wget -q --spider http://google.com; do | |
echo "Waiting for internet connection..." | |
sleep 1 | |
done | |
fi | |
# Autologin | |
#sed -i "s/sbin\/getty 38400 tty1/sbin\/agetty --autologin $TARGETUSER --noclear 38400 tty1/" /etc/inittab | |
# Brightness. Works at kernel fork only yet | |
echo 0 > /sys/class/backlight/lcd-backlight/brightness | |
apk update | |
apk upgrade | |
apk add curl vim git htop upower libcgroup docker | |
# Set MAC at boot. Only for OnePlus (bacon) | |
read -r -d '' FILECONTENT <<'ENDFILECONTENT' | |
#!/sbin/openrc-run | |
command=/sbin/ip | |
command_args="link set dev wlan0 address be:3c:4e:4e:74:97" | |
description="WLAN hw-addr setter" | |
depend() { | |
before networkmanager | |
} | |
ENDFILECONTENT | |
echo "$FILECONTENT" > /etc/init.d/wlanhwaddr | |
chmod 755 /etc/init.d/wlanhwaddr | |
rc-update add wlanhwaddr default | |
# nftables for Docker | |
read -r -d '' FILECONTENT <<'ENDFILECONTENT' | |
table inet filter { | |
chain input { | |
iifname "wlan*" accept comment "Allow incoming network traffic from WLAN" | |
} | |
chain forward { | |
iifname "wlan*" accept comment "Allow outgoing network traffic from WLAN through us" | |
ct state {established, related} counter accept comment "accept established connections" | |
} | |
} | |
ENDFILECONTENT | |
echo "$FILECONTENT" > /etc/nftables.d/52_wlan_inet.nft | |
rc-service nftables restart | |
# Preparing /sdcard | |
mkdir /sdcard | |
mount PARTLABEL=userdata /sdcard | |
while ! mountpoint -q /sdcard; do | |
echo "Wait for mount /sdcard" | |
sleep 1 | |
done | |
mkdir /sdcard/media | |
mkdir /sdcard/media/home | |
mkdir /sdcard/media/docker | |
chmod 755 /sdcard/media /sdcard/media/home /sdcard/media/docker | |
# Prepare our filesystem | |
mv /home /home.bak | |
mkdir /home | |
mkdir /var/lib/docker | |
read -r -d '' FILECONTENT <<'ENDFILECONTENT' | |
# <device> <dir> <type> <options> <dump> <fsck> | |
PARTLABEL=userdata /sdcard ext4 rw,user,suid,dev,exec,auto,users,async 0 2 | |
/sdcard/media/home /home none bind 0 0 | |
/sdcard/media/docker /var/lib/docker none bind 0 0 | |
ENDFILECONTENT | |
echo "$FILECONTENT" > /etc/fstab | |
mount -a | |
while ! mountpoint -q /home; do | |
echo "Wait for mount /home. If failed you should rename /home.bak to /home explicitly" | |
sleep 1 | |
done | |
cp -r -p /home.bak/* /home | |
rc-update add localmount default | |
# Prepare Docker | |
usermod -aG docker ${TARGET_USER} | |
rc-update add docker | |
rc-service docker start | |
while [ ! -S /var/run/docker.sock ]; do | |
sleep 1 | |
done | |
sleep 2 | |
# Prepare Docker for Prometheus | |
readonly DOCKER_GATEWAY_HOST=$(ip addr show docker0 | awk '/inet / {print $2}' | head -n1 | cut -f1 -d '/') | |
cat > /etc/docker/daemon.json <<EOF | |
{ | |
"metrics-addr" : "${DOCKER_GATEWAY_HOST}:9323", | |
"experimental" : true | |
} | |
EOF | |
rc-service docker reload | |
docker swarm init --advertise-addr wlan0 |
Is there something which needs to be updated? @valentino-sm
@MasterPlexus Yep. This patch is needed for backlight support:
msm8974-mainline/linux#2
Patching the kernel is non-trivial task, however it will work if you deal with it.
Thanks. In between I've seen your patch. Unfortunately when I compare it to the current mainline source, I did not find the corresponding file, which you have patched...
I see the backlight switch as important, as it makes no Sense to let it on, even the phone should only run as a kind of server... So any help on that will be very appreciated ;)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The brightnes line is not workuing for me. I could See that in class the brightness is not avalible in mainline kernel. The upstrem has the brightnes in a other class folder... Is there something which needs to be updated? @valentino-sm