# Smart Diaper Gateway OS ### OS install to SD CARD ### Raspberry Pi Manager Raspberry Pi OS (other) -> Raspberry Pi OS Lite option -> SSH enable -> wifi country KR -> locale Asia/Seoul ### get gw install script from git server ## ``` curl -k -O https://onioi.com:8443/raw/MEDILOGIS/gwinstall.git/master/gwinstall.sh ``` ### install SSH tunnel service on RPi4 ### ``` #!/bin/bash export FWD_PORT=10000 if [ ! $1 ]; then echo -e "USAGE:\nex) gwinstall.sh 10000" exit 1 else FWD_PORT=$1 fi sudo ssh-keygen sudo ssh-copy-id -p 12222 root@onio.iptime.org echo " [Unit] Description=SSH Tunnel with target server After=network.target [Service] ExecStart=/usr/bin/ssh -NT -o ServerAliveInterval=60 -o ExitOnForwardFailure=yes -R 127.0.0.1:$FWD_PORT:localhost:22 -p 12222 root@onio.iptime.org RestartSec=5 Restart=always [Install] WantedBy=multi-user.target " | sudo tee /etc/systemd/system/tunnel.service > /dev/null sudo systemctl daemon-reload sudo systemctl start tunnel sudo systemctl enable tunnel sudo systemctl status tunnel ``` ### Change sshd_config ### ``` sudo vi /etc/ssh/sshd_config ``` ``` AllowTcpForwarding yes GatewayPorts yes ``` ``` sudo service ssh restart ``` ### Check server side RPi4 SSH tunnel port ### ``` netstat -tulpn ``` ### Connect to RPi4 via SSH tunnel ### ``` ssh -J root@onio.iptime.org:12222 -p 10000 medi@localhost ``` ### install packages ### ``` sudo apt-get update sudo apt install -y git nodejs npm bluetooth bluez libbluetooth-dev libudev-dev bluez-hcidump sudo setcap cap_net_raw+eip $(eval readlink -f `which node`) ``` ### RPi 4 USB WiFi tplink archer t2 plus ### ``` sudo apt install -y git dkms raspberrypi-kernel-headers build-essential bc git clone https://github.com/aircrack-ng/rtl8812au.git cd rtl8812au sed -i 's/CONFIG_PLATFORM_I386_PC = y/CONFIG_PLATFORM_I386_PC = n/g' Makefile sed -i 's/CONFIG_PLATFORM_ARM_RPI = n/CONFIG_PLATFORM_ARM_RPI = y/g' Makefile sudo make dkms_install ``` ### RPi4 internal WiFi disable & USB WiFi enable wlan0 ### /boot/config.txt append ``` dtoverlay=disable-wifi ``` and reboot ### RPi 4 Korean font install ### ``` sudo apt install -y fonts-unfonts-core ``` ### RPi 4 measure temp ### ``` vcgencmd measure_temp ``` ### RPi 4 SD Card wifi setting ### Put the wpa_supplicant.conf file with the following contents in /boot folder of the sd card. When the setting is completed, the x file will be deleted from the /boot folder of the sd card. ``` country=KR # Your 2-digit country code ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev network={ ssid="wifi ssid" psk="widi passwd" } ``` ### WireGuard ### ``` sudo apt install wireguard sudo vi /etc/wireguard/wg0.conf sudo vi /etc/network/interfaces.d/wg0 sudo ifup wg0 ip route get 10.8.0.1 ping -c 3 10.8.0.1 sudo wg show wg0 ``` ### TODO ### ### ref ### USB WiFi tplink archer t2 plus ( https://github.com/nlkguy/archer-t2u-plus-linux )