Created
February 13, 2016 10:15
-
-
Save phieber/a570166790f0f8d15dc8 to your computer and use it in GitHub Desktop.
Script which creates new builds for the RaspberryPi. Those builds are pushed to https://rpi.pa.trickhieber.de .
This file contains hidden or 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/bash | |
# | |
# Author: Patrick Hieber - github.com/phieber | |
# | |
# This work is licensed under a GNU General Public License (GPLv3) Version 3.0 http://www.gnu.org/licenses/gpl-3.0.html | |
cleanup() { | |
rm -rf /tmp/Gentoo* /tmp/root.tar.xz /tmp/boot.tar.xz /tmp/*.json /tmp/partition_setup.sh /tmp/rpi* | |
find /var/www/de/trickhieber/pa/rpi/htdocs/geNtOOBS* -mtime +1 -exec rm {} \; | |
} | |
cleanup | |
mkdir /tmp/rpi | |
mkdir /tmp/Gentoo | |
MIRROR=$(mirrorselect -oqF | grep '^GENTOO_MIRRORS' | tr '"' ' ' | awk '{print $2}') | |
wget -c -O - ${MIRROR}releases/arm/autobuilds/current-stage3-armv6j_hardfp/$(wget -q -O - ${MIRROR}releases/arm/autobuilds/current-stage3-armv6j_hardfp/ | grep -e 'armv6j_hardfp-[0-9][0-9]*\.tar\.bz2"' | sed -e 's@^.*/\(stage3[^"]*\)".*@\1@g;') | tar xfpj - -C /tmp/rpi | |
wget -c -O - ${MIRROR}snapshots/portage-latest.tar.xz | tar xJf - -C /tmp/rpi/usr | |
git clone --depth 1 git://github.com/raspberrypi/firmware/ /tmp/rpiFirmware | |
set -x | |
cp /tmp/rpiFirmware/boot/* /tmp/rpi/boot/ | |
cp -r /tmp/rpiFirmware/modules /tmp/rpi/lib/ | |
sed -ie 's@^/@#/@g;' /tmp/rpi/etc/fstab | |
echo -e '@BOOT@\t/boot\tvfat\tdefaults\t0\t0' >> /tmp/rpi/etc/fstab | |
# http://raspberrypi.stackexchange.com/questions/27162/readonly-filesystem-after-reboot | |
echo 'ipv6.disable=1 avoid_safe_mode=1 selinux=0 plymouth.enable=0 smsc95xx.turbo_mode=N dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=@ROOT@ rootfstype=ext4 elevator=noop rw rootwait' > /tmp/rpi/boot/cmdline.txt | |
sed -ie 's@^\(root:\)\*\(.*\)@\1$6$sWmzkD4k$c0mMp/uShHALAPSnYyECig8FxOMUQZ7nf2uUPF/xj2iCD13qDpEE69V.8MuqkGW27i7gQNQ8neDhUDizTfcCb0\2@g;' /tmp/rpi/etc/shadow | |
echo '#!/bin/bash | |
# | |
# author: Patrick Hieber <rpi.p AT trickhieber.de> | |
# url: https://rpi.pa.trickhieber.de | |
cp /etc/init.d/net.lo /etc/init.d/net.eth0 | |
rc-config start net.eth0 | |
rc-update add net.eth0 boot | |
sleep 10 | |
sed -ie "s@^s0:@#s0:@" /etc/inittab | |
rc-update add swclock boot | |
rc-update del hwclock boot | |
/etc/init.d/swclock start | |
# fix timestamp problem for the next emerge | |
currentTS=$(date -d $(wget -O - http://www.timeapi.org/utc/now 2>/dev/null)) | |
date -s "$currentTS" | |
emerge --sync | |
rc-update add sshd default | |
/etc/init.d/sshd start | |
#emerge --autounmask-write ntpclient | |
#etc-update <<-EOI | |
#-3 | |
#EOI | |
#emerge ntpclient && rc-update add ntp-client default | |
echo 'ACCEPT_LICENSE="-* @GPL-COMPATIBLE"' >> /etc/portage/make.conf | |
emerge --sync | |
' > /tmp/rpi/root/runOnce.sh | |
echo '#!/bin/bash | |
# | |
# author: Patrick Hieber <rpi.p AT trickhieber.de> | |
# url: https://rpi.pa.trickhieber.de | |
# update the timestamp over the internet | |
currentTS=$(date -d $(wget -O - http://www.timeapi.org/utc/now 2>/dev/null)) | |
date -s "$currentTS" | |
' > /tmp/rpi/etc/cron.daily/ntpViaINet.sh | |
chmod a+x /tmp/rpi/etc/cron.daily/ntpViaINet.sh | |
chmod a+x /tmp/rpi/root/runOnce.sh | |
cp /tmp/rpi/usr/share/zoneinfo/Europe/Berlin /tmp/rpi/etc/localtime | |
echo 'Europe/Berlin' > /tmp/rpi/etc/timezone | |
echo ' | |
{ | |
"partitions": [ | |
{ | |
"label": "boot", | |
"filesystem_type": "FAT", | |
"partition_size_nominal": 100, | |
"want_maximised": false, | |
"uncompressed_tarball_size": 26, | |
"mkfs_options": "-F 32" | |
}, | |
{ | |
"label": "root", | |
"filesystem_type": "ext4", | |
"partition_size_nominal": 2500, | |
"want_maximised": true, | |
"mkfs_options": "-c", | |
"uncompressed_tarball_size": '$(du -s /tmp/rpi/ | awk '{SAFESTORE = (($1+5000)/1000)} END {OFMT = "%.0f" ; print SAFESTORE}')' | |
} | |
] | |
}' > /tmp/Gentoo/partitions.json | |
echo ' | |
{ | |
"name": "Gentoo", | |
"url": "https://rpi.pa.trickhieber.de", | |
"version": "'$(date +%Y%m%d)'", | |
"release_date": "'$(date +%Y-%m-%d)'", | |
"kernel": "'$(ls /tmp/rpiFirmware/modules | tr -d +)'", | |
"description": "Gentoo Linux for the RPI", | |
"username": "root", | |
"password": "root" | |
} | |
' > /tmp/Gentoo/os.json | |
echo ' | |
#!/bin/bash | |
# NOOBS partition setup script for Gentoo Linux ARM | |
# - part1 == boot partition (FAT), part2 == root partitions (ext4) | |
# - example usage: | |
# part1=/dev/mmcblk0p7 part2=/dev/mmcblk0p8 ./partition_setup.sh | |
# extract and set part1 and part2 variables | |
if [[ ${part1} == '' || ${part2} == '' ]]; then | |
echo "error: part1 and part2 not specified" | |
exit 1 | |
fi | |
# create mount points | |
mkdir /tmp/1 | |
mkdir /tmp/2 | |
# mount partitions | |
mount ${part1} /tmp/1 | |
mount ${part2} /tmp/2 | |
# adjust files | |
sed -ie "s|@ROOT@|${part2}|" /tmp/1/cmdline.txt | |
sed -ie "s|@BOOT@|${part1}|" /tmp/2/etc/fstab | |
# clean up | |
umount /tmp/1 | |
umount /tmp/2 | |
' > /tmp/Gentoo/partition_setup.sh | |
cd /tmp/rpi/boot && tar -Ipixz -cpf /tmp/Gentoo/boot.tar.xz . | |
cd /tmp/rpi && tar -Ipixz -cpf /tmp/Gentoo/root.tar.xz . --exclude=proc/* --exclude=sys/* --exclude=dev/pts/* --exclude=boot/* | |
cd /tmp | |
mkdir -p Gentoo/slides_vga | |
wget -q --no-check-certificate -O /tmp/Gentoo/Gentoo.png https://rpi.pa.trickhieber.de/g-logo-40x40.png | |
cd /tmp && tar -Ipixz -cpf /var/www/de/trickhieber/pa/rpi/htdocs/geNtOOBS-$(date +%Y%m%d).tar.xz Gentoo/ | |
cd /var/www/de/trickhieber/pa/rpi/htdocs && sha1sum geNtOOBS-$(date +%Y%m%d).tar.xz > geNtOOBS-$(date +%Y%m%d).tar.xz.sha1sum | |
cd /var/www/de/trickhieber/pa/rpi/htdocs && ln -sf geNtOOBS-$(date +%Y%m%d).tar.xz geNtOOBS-latest.tar.xz | |
cd /var/www/de/trickhieber/pa/rpi/htdocs && ln -sf geNtOOBS-$(date +%Y%m%d).tar.xz.sha1sum geNtOOBS-latest.tar.xz.sha1sum | |
chown -R apache:apache /var/www | |
cleanup |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello, please remove the ntpViaINet.sh the domain is now parked and will created strange date stamps