# https://github.com/nopmop/picore-headless-setup/raw/master/picore-headless-setup.sh | |
# Raspberry Pi Zero W | |
# TinyCoreLinux | |
# Headless SetUp | |
# D0N'T RUN THI5 !!! | |
exit 2 | |
# * Arch: armv6 | |
# * PiCore: 11.x - 11.0 | |
# * Kernel: 4.19.81-piCore | |
# "wget" "md5sum" "unzip" "sudo" | |
# "dd" "losetup" "kpartx" "parted" "e2fsck" "resize2fs" "mount" "umount" # "partx" | |
# "cat" "awk" "tar" | |
mkdir ./piCore-11.0 | |
mkdir ./piCore-11.0/mnt1 | |
mkdir ./piCore-11.0/mnt2 | |
mkdir ./piCore-11.0/filesystem | |
mkdir -p ./piCore-11.0/pkg/tce/optional | |
wget -c 'http://distro.ibiblio.org/tinycorelinux/11.x/armv6/releases/RPi/piCore-11.0.zip' -P ./piCore-11.0 | |
unzip -o ./piCore-11.0/piCore-11.0.zip -d ./piCore-11.0 | |
nano ./piCore-11.0/pkg-to-dl.txt | |
# ========================================= BoF | |
haveged.tcz | |
haveged.tcz.md5.txt | |
ca-certificates.tcz | |
ca-certificates.tcz.md5.txt | |
file.tcz | |
file.tcz.md5.txt | |
libnl.tcz | |
libnl.tcz.md5.txt | |
nano.tcz | |
nano.tcz.dep | |
nano.tcz.md5.txt | |
ncurses.tcz | |
ncurses.tcz.md5.txt | |
ncurses-terminfo.tcz | |
ncurses-terminfo.tcz.dep | |
ncurses-terminfo.tcz.md5.txt | |
net-usb-4.19.81-piCore.tcz | |
net-usb-4.19.81-piCore.tcz.md5.txt | |
openssh.tcz | |
openssh.tcz.dep | |
openssh.tcz.md5.txt | |
openssl.tcz | |
openssl.tcz.dep | |
openssl.tcz.md5.txt | |
readline.tcz | |
readline.tcz.dep | |
readline.tcz.md5.txt | |
wireless-4.19.81-piCore.tcz | |
wireless-4.19.81-piCore.tcz.md5.txt | |
wireless_tools.tcz | |
wireless_tools.tcz.dep | |
wireless_tools.tcz.md5.txt | |
wpa_supplicant.tcz | |
wpa_supplicant.tcz.dep | |
wpa_supplicant.tcz.md5.txt | |
firmware-rpi-wifi.tcz | |
firmware-rpi-wifi.tcz.md5.txt | |
#_9 | |
firmware-rpi3-wireless.tcz | |
firmware-rpi3-wireless.tcz.md5.txt | |
libiw.tcz | |
libiw.tcz.md5.txt | |
# ========================================= EoF | |
wget -c -B http://distro.ibiblio.org/tinycorelinux/11.x/armv6/tcz/ -i ./piCore-11.0/pkg-to-dl.txt -P ./piCore-11.0/pkg/tce/optional/ | |
sudo touch ./piCore-11.0/piCore-11.0.custom.img | |
# 204800 # 512 * 204800 = 104857600 (~100MB) # $(((100*1024*1024)/512)) | |
# 409600 # 512 * 409600 = 209715200 (~200MB) # $(((200*1024*1024)/512)) | |
sudo dd bs=512 count=409600 if=/dev/zero of=./piCore-11.0/piCore-11.0.custom.img | |
sudo losetup -f --show ./piCore-11.0/piCore-11.0.img | |
#: loop0 | |
sudo losetup -f --show ./piCore-11.0/piCore-11.0.custom.img | |
#: loop1 | |
sudo dd if=/dev/loop0 of=/dev/loop1 | |
sudo losetup -d /dev/loop0 /dev/loop1 | |
# sed -e ':a;N;$!ba;s/\n//g' | awk'{ print $1 }' | |
sudo kpartx -l ./piCore-11.0/piCore-11.0.custom.img | awk '{ print $1 }' | |
#: loop0p1 loop0p2 | |
sudo kpartx -a ./piCore-11.0/piCore-11.0.custom.img | |
ln -s /dev/mapper/loop0p1 ./piCore-11.0/piCore-11.0.custom.img1 | |
ln -s /dev/mapper/loop0p2 ./piCore-11.0/piCore-11.0.custom.img2 | |
# sed -e ':a;N;$!ba;s/\n//g' | sed -e 's/s//g' | awk '{ print $3 $1 }' | |
sudo parted -m -s ./piCore-11.0/piCore-11.0.custom.img unit s print | awk -F : '{print $2}' | |
#: (409800s-1) ... 195693s | |
sudo parted -s ./piCore-11.0/piCore-11.0.custom.img unit s rm 2 | |
sudo parted -s ./piCore-11.0/piCore-11.0.custom.img unit s mkpart primary 195693 409599 | |
sudo kpartx -d ./piCore-11.0/piCore-11.0.custom.img | |
sudo kpartx -a ./piCore-11.0/piCore-11.0.custom.img | |
ln -s /dev/mapper/loop0p1 ./piCore-11.0/piCore-11.0.custom.img1 | |
ln -s /dev/mapper/loop0p2 ./piCore-11.0/piCore-11.0.custom.img2 | |
sudo e2fsck -f ./piCore-11.0/piCore-11.0.custom.img2 | |
sudo resize2fs ./piCore-11.0/piCore-11.0.custom.img2 | |
sudo mount ./piCore-11.0/piCore-11.0.custom.img1 ./piCore-11.0/mnt1 | |
sudo mount ./piCore-11.0/piCore-11.0.custom.img2 ./piCore-11.0/mnt2 | |
sudo rsync -avz ./piCore-11.0/pkg/tce/optional/* ./piCore-11.0/mnt2/tce/optional/ | |
sudo nano ./piCore-11.0/mnt2/tce/onboot.lst | |
# ========================================= BoF | |
haveged.tcz | |
firmware-rpi3-wireless.tcz # 9.x | |
firmware-rpi-wifi.tcz | |
wireless_tools.tcz | |
wpa_supplicant.tcz | |
# ========================================= EoF | |
sudo mkdir -p ./piCore-11.0/mnt2/tce/mydata | |
sudo tar zxvf ./piCore-11.0/mnt2/tce/mydata.tgz -C ./piCore-11.0/mnt2/tce/mydata | |
sudo nano ./piCore-11.0/mnt2/tce/mydata/opt/wpa_supplicant.conf | |
# ========================================= BoF | |
#country=US | |
ctrl_interface=/var/run/wpa_supplicant | |
#ctrl_interface_group=0 | |
eapol_version=1 | |
update_config=1 | |
ap_scan=1 | |
fast_reauth=1 | |
network={ | |
ssid="MyHomeWariFaiFa" | |
#key_mgmt=NONE | |
psk="ChapaLaPachala" | |
key_mgmt=WPA-PSK | |
pairwise=CCMP TKIP | |
group=CCMP TKIP | |
scan_ssid=1 | |
priority=97 | |
} | |
#network={ | |
#key_mgmt=NONE | |
#priority=-999 | |
#} | |
# ========================================= EoF | |
sudo sh -c "echo opt/wpa_supplicant.conf >> ./piCore-11.0/mnt2/tce/mydata/opt/.filetool.lst" | |
sudo nano ./piCore-11.0/mnt2/tce/mydata/opt/bootlocal.sh | |
# ========================================= BoF | |
#!/bin/sh | |
# SSH Fix (low-entropy) | |
/usr/local/sbin/haveged & | |
# ========================================= EoF | |
# ========================================= BoF | |
sleep 2 | |
#echo -en "piCore\npiCore" | passwd tc | |
#mount | grep -qo "mmcblk0p1" || { | |
# [ -d /mnt/mmcblk0p1 ] || mkdir /mnt/mmcblk0p1 | |
# mount /dev/mmcblk0p1 /mnt/mmcblk0p1 | |
# [ -f /mnt/mmcblk0p1/wpa_supplicant.conf ] && cp -f /mnt/mmcblk0p1/wpa_supplicant.conf /opt/wpa_supplicant.conf | |
# umount /mnt/mmcblk0p1 | |
#} | |
sleep 0.1 | |
# Networking setup - Wireless CONNECT | |
/usr/local/sbin/wpa_supplicant -B -D wext -i wlan0 -c /opt/wpa_supplicant.conf & | |
# Networking setup - Wireless IP | |
/sbin/udhcpc -b -i wlan0 -x hostname:$(/bin/hostname) -p /var/run/udhcpc.wlan0.pid & | |
#/sbin/ifconfig wlan0 192.168.8.8 netmask 255.255.255.0 broadcast 192.168.8.255 up | |
# Networking setup - Ethernet IP | |
#/sbin/udhcpc -b -i eth0 -x hostname:$(/bin/hostname) -p /var/run/udhcpc.eth0.pid & | |
#/sbin/ifconfig eth0 192.168.8.9 netmask 255.255.255.0 broadcast 192.168.8.255 up | |
# Networking setup - for STATIC_IP | |
#/sbin/route add default gw 192.168.8.1 | |
#echo 'nameserver 192.168.8.1' > /etc/resolv.conf | |
# Start openssh daemon | |
#/usr/local/etc/init.d/openssh start | |
# User | |
export LANG=C | |
[ -f /mnt/mmcblk0p2/tce/home.d/hbind.sh ] && chmod 755 /mnt/mmcblk0p2/tce/home.d/hbind.sh | |
[ -f /mnt/mmcblk0p2/tce/home.d/hbind.sh ] && /mnt/mmcblk0p2/tce/home.d/hbind.sh >/dev/null 2>&1 | |
[ -d /home/tc/.local/bin ] && chmod -R 755 /home/tc/.local/bin | |
[ -f /home/tc/.local/bin/scrpt.src ] && /home/tc/.local/bin/scrpt.src >/dev/null 2>&1 | |
# ========================================= EoF | |
CWD=$(pwd) | |
cd ./piCore-11.0/mnt2/tce/mydata | |
sudo tar -zcf ../mydata.tgz . | |
cd ${CWD} | |
sudo sh -c 'chmod a+rwx ./piCore-11.0/filesystem' | |
sudo sh -c 'zcat ./piCore-11.0/mnt1/11.0.gz | (cd ./piCore-11.0/filesystem && sudo cpio -i -H newc -d)' | |
sudo nano ./piCore-11.0/filesystem/usr/sbin/startserialtty | |
# ========================================= BoF | |
elif [ "${model:0:19}" = "Raspberry Pi Zero W" ]; then port=ttyS0 | |
# ========================================= EoF | |
sudo sh -c '(cd ./piCore-11.0/filesystem && find | cpio -o -H newc) | gzip -2 > ./piCore-11.0/mnt1/11.0.gz' | |
sudo umount ./piCore-11.0/mnt1 | |
sudo umount ./piCore-11.0/mnt2 | |
rm -rf ./piCore-11.0/mnt1 | |
rm -rf ./piCore-11.0/mnt2 | |
sudo kpartx -d ./piCore-11.0/piCore-11.0.custom.img | |
rm ./piCore-11.0/piCore-11.0.custom.img1 | |
rm ./piCore-11.0/piCore-11.0.custom.img2 | |
sudo rm -rf ./piCore-11.0/filesystem | |
ls -lh ./piCore-11.0/piCore-11.0.custom.img | |
# --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- | |
sudo dd if=./piCore-11.0/piCore-11.0.custom.img of=/dev/sdX bs=4M iflag=fullblock oflag=direct status=progress | |
ssh tc@${SSH_IP:-192.168.8.100} -p ${SSH_PORT:-22} #-i ~/id_rsa | |
# SSH key | |
#OR# ./piCore-11.0/mnt2/tce/mydata.tgz ./piCore-11.0/mnt2/tce/mydata/home/tc | |
# tc@box~$ mkdir ${HOME}/.ssh | |
# tc@box~$ ssh-keygen -t rsa -b 2048 -C "tc@box" -f ${HOME}/.ssh/id_rsa | |
# tc@box~$ cat ${HOME}/.ssh/id_rsa.pub ${HOME}/.ssh/authorized_keys | |
# tc@box~$ filetool.sh -b | |
# SD Resize | |
# tc@box~$ sudo fdisk -u /dev/mmcblk0 | |
# p | |
# d 2 n p 2 | |
# {StartLBA} | |
# {EndLBA} | |
# w | |
# tc@box~$ exitcheck.sh reboot | |
# tc@box~$ sudo resize2fs /dev/mmcblk0p2 | |
# busybox addgroup -g 50 staff | |
# busybox adduser -D -H -G staff -u 1001 -s /bin/sh tc | |
# busybox adduser -D -h /tmp/squid -G staff -u 1001 -s /bin/sh tc | |
# busybox adduser -D -h ./piCore-11.0/mnt2/tce/mydata/home/tc -G staff -u 1001 -s /bin/sh tc | |
# K M G | |
# $(((512*SECTORS)/1024/1024/1024)) | |
# mmcblk0p2_StartLBA = mmcblk0p1_EndLBA + 1 | |
# mmcblk0p2_EndLBA = mmcblk0_EndLBA - 1 | |
#% fdisk -u /dev/mmcblk0 | |
#% # p # d 2 n p 2 # w | |
#% reboot | |
#% resize2fs /dev/mmcblk0p2 | |
#%#e2fsck -f /dev/mmcblk0p2 | |
#ssh-keygen -t ed25519 # ed25519.sshkey | |
#cat ed25519.sshkey.pub >> ${HOME}/.ssh/authorized_keys | |
##% fdisk -l piCore-11.0.img | |
##% mkdir /tmp/mnt0p1 | |
##% mount -o loop,ro,offset=$((512*StartLBA)) piCore-11.0.img /tmp/mnt0p1 | |
##% dd if=piCore-11.0.img of=/dev/sdX bs=4M iflag=fullblock oflag=direct status=progress | |
##% fdisk -l raspios-buster-lite-armhf.img | |
##% mkdir /tmp/mnt0p1 /tmp/mnt0p2 | |
##% mount -t vfat -o ro,offset=$((512*StartLBA)),sizelimit=$((512*Sectors)) raspios-buster-lite-armhf.img /tmp/mnt0p1 | |
##% mount -t ext4 -o ro,offset=$((512*StartLBA)),sizelimit=$((512*Sectors)) raspios-buster-lite-armhf.img /tmp/mnt0p2 | |
#+nano | |
# ++file | |
# ++ncurses-terminfo | |
# +++ncurses | |
#+screen | |
# ++libelf | |
# ++ncurses | |
#+net-usb-KERNEL | |
#+openssh | |
# ++openssl | |
# +++ca-certificates | |
#+firmware-rpi-wifi | |
#+firmware-rpi3-wireless #_9 | |
#+wireless_tools | |
# ++libiw #_9 | |
# ++wireless-KERNEL | |
#+wpa_supplicant | |
# ++libnl | |
# ++openssl | |
# +++ca-certificates | |
# ++readline | |
# +++ncurses | |
# "compiletc" "bzip2" "sstrip" "git" "perl5" "squashfs-tools" "automake" "libtool" | |
## http://repo.tinycorelinux.net/11.x/armv6/releases/RPi/src/kernel/modules.tar.gz | |
## /usr/local/lib/modules/4.19.81-piCore/kernel/... | |
## net-bridging-4.19.81-piCore.tcz | |
## tar tf /tmp/modules.tar.gz | grep -E "net/802|llc|bridge" | grep -v "/$"> /tmp/bridging.txt | |
## usb-gadget-4.19.81-piCore.tcz | |
## tar tf /tmp/modules.tar.gz | grep -E "dwc2|gadget" | grep -v "/$"> /tmp/gadget.txt | |
# * PiCore: 9.x - 9.0.3 | |
# * Kernel: 4.9.22-piCore | |
# cat piCore-11.0.custom.txt | sed 's/11.0/9.0.3/g; s/11.x/9.x/g; s/4.19.81/4.9.22/g' | |
# sudo chmod u=rwx,g=rx,o=rx tc | |
# sudo chown --reference=A B | |
# partprobe | |
# partx -a | |
# truncate -s | |
# losetup -d | |
# cat <<__EOF__> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment