diff --git a/maketiny b/maketiny index 789d96a..a44acba 100755 --- a/maketiny +++ b/maketiny @@ -2,5 +2,6 @@ rm -rf boot_tiny mkdir boot_tiny ssh l_samenv@linse-c "cd boxes/boot_tiny ; tar -cf - *" | tar -C boot_tiny/ -xf - -cd boot_tiny -sudo bash makeusb $1 +sudo bash boot_tiny/makeusb $1 +rm -rf boot_tiny + diff --git a/tinylinux/bootlocal.sh b/tinylinux/bootlocal.sh deleted file mode 100644 index 53fe27e..0000000 --- a/tinylinux/bootlocal.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh -# /opt/bootlocal.sh - run as root at the end of boot (called by tc-config). -# Everything needed is already inside core.gz: no network, no tce-load. - -# do what tce-load does after it has mounted an extension -ldconfig 2> /dev/null -for f in /usr/local/tce.installed/*; do - [ -x "$f" ] && "$f" -done - -# passwords (delete these two lines if only key login is wanted) -echo "tc:tc" | chpasswd -echo "root:root" | chpasswd - -# ssh files for user tc, staged in /opt/ssh by build_core.sh -if [ -d /opt/ssh ]; then - rm -rf /home/tc/.ssh - cp -a /opt/ssh /home/tc/.ssh - chown -R tc:staff /home/tc/.ssh - chmod 700 /home/tc/.ssh - chmod -R go-rwx /home/tc/.ssh -fi - -/usr/local/etc/init.d/openssh start - -# marker so that you can see on the box that this script ran -echo "bootlocal.sh finished $(date)" > /tmp/bootlocal.log diff --git a/tinylinux/build_core.sh b/tinylinux/build_core.sh deleted file mode 100644 index c70e9cf..0000000 --- a/tinylinux/build_core.sh +++ /dev/null @@ -1,129 +0,0 @@ -#!/bin/bash -# Build a custom core.gz for the BOOT_TINY stick: -# - nano, lz4, openssh (and their dependencies) are built in, so no -# network and no tce-load are needed at boot -# - /opt/bootlocal.sh starts sshd and sets up ~/.ssh -# - the ssh/ directory (authorized_keys, id_rsa, ...) is staged in /opt/ssh -# - the stick gets a hostname and its own, fixed ssh host keys -# -# Needs: root, cpio, gzip, unsquashfs (package squashfs-tools), ssh-keygen -# -# Put these next to this script: -# core.gz.orig the original, unmodified core.gz (keep it, never overwrite) -# tcz/*.tcz extensions fetched on the Tiny Core box with -# "tce-load -w nano lz4 openssh", copied from tce/optional -# ssh/ files for ~/.ssh of user tc (authorized_keys, ...) -# bootlocal.sh -# sticks//hostkeys/ ssh host keys of the stick called . Used if it -# exists, created (and filled with new keys) if it does not. -# Keep it, then a rebuilt stick keeps its identity. -# Result: sticks//core.gz (copy it into boot_tiny/ and commit it) -set -e -cd "$(dirname "$0")" - -ORIG=core.gz.orig - -[ "$EUID" -eq 0 ] || { echo "Please run as root"; exit 1; } -for f in "$ORIG" bootlocal.sh; do - [ -f "$f" ] || { echo "missing $f"; exit 1; } -done -ls tcz/*.tcz > /dev/null 2>&1 || { echo "no tcz/*.tcz found"; exit 1; } -for c in cpio gzip unsquashfs ssh-keygen; do - command -v $c > /dev/null || { echo "need $c"; exit 1; } -done - -file "$ORIG" | grep -q gzip || { echo "$ORIG is not gzip compressed:"; file "$ORIG"; exit 1; } - -if [ -z "$1" ]; then - read -p "stick name [apu-boot]: " stickname - stickname=${stickname:-apu-boot} -else - stickname=$1 -fi -label=${stickname//-/_} -label=${label^^} - -# the name ends up in a directory name and in a script: allow only safe characters -case "$stickname" in - *[!A-Za-z0-9-]*|.*) echo "invalid hostname '$stickname' (use letters, digits and dash only)"; exit 1 ;; -esac - -# ssh host keys: use hostkeys_ if present, create missing keys otherwise -STICKDIR=$PWD/sticks/$stickname -KEYDIR=$STICKDIR/hostkeys -SSHDIR=$PWD/tmp/ssh_for_boxes -if [ -d "$KEYDIR" ]; then - echo "using ssh host keys from $KEYDIR" -else - echo "creating $KEYDIR with new ssh host keys" - mkdir -p "$KEYDIR" -fi -for t in dsa rsa ecdsa ed25519; do - if [ ! -f "$KEYDIR/ssh_host_${t}_key" ]; then - echo " generate $t key" - rm -f "$KEYDIR/ssh_host_${t}_key.pub" - ssh-keygen -q -t $t -N '' -f "$KEYDIR/ssh_host_${t}_key" - fi -done - -cat << EOF > $STICKDIR/bootsync.sh -#!/bin/sh -# put other system startup commands here, the boot process will wait until they complete. -# Use bootlocal.sh for system startup commands that can run in the background -# and therefore not slow down the boot process. -/usr/bin/sethostname $stickname -/opt/bootlocal.sh & -EOF - -WORK=$(mktemp -d) -TMP=$(mktemp -d) -trap 'rm -rf "$WORK" "$TMP"' EXIT - -echo "unpack $ORIG" -zcat "$ORIG" | (cd "$WORK" && cpio -idm --quiet) - -for t in tcz/*.tcz; do - echo "add $t" - rm -rf "$TMP/x" - unsquashfs -d "$TMP/x" "$t" > /dev/null - cp -a "$TMP/x/." "$WORK/" -done - -echo "add ssh files from $SSHDIR for user tc host" - -if [ -d "$SSHDIR" ]; then - echo "stage $SSHDIR in /opt/ssh" - mkdir -p "$WORK/opt/ssh" - cp -a "$SSHDIR"/. "$WORK/opt/ssh/" -fi - -echo "add ssh host keys from $KEYDIR" - -mkdir -p "$WORK/usr/local/etc/ssh" -for k in "$KEYDIR"/ssh_host_*_key; do - install -m 600 -o root -g root "$k" "$WORK/usr/local/etc/ssh/" - install -m 644 -o root -g root "$k.pub" "$WORK/usr/local/etc/ssh/" -done - -install -m 755 -o root -g root bootlocal.sh "$WORK/opt/bootlocal.sh" -install -m 755 -o root -g root $STICKDIR/bootsync.sh "$WORK/opt/bootsync.sh" - -# commands whose scripts live on the stick: small wrappers in /usr/local/bin -STICKCMDS="clone write_to_ssd" -mkdir -p "$WORK/usr/local/bin" -for c in $STICKCMDS; do - printf '#!/bin/sh\ncd %s && exec bash ./%s "$@"\n' "/media/$label" "$c" > "$WORK/usr/local/bin/$c" - chmod 755 "$WORK/usr/local/bin/$c" -done - -OUT=core.gz -echo "pack $STICKDIR/$OUT" -(cd "$WORK" && find . | cpio -o -H newc --quiet) | gzip -9 > "${OUT}.new" - -mv "${OUT}.new" $STICKDIR/$OUT - -# change ownership of generated files to the owner of the current directory -chown -R --reference=. $STICKDIR - -ls -l "$STICKDIR/$OUT" -echo "done." diff --git a/tinylinux/core.gz.orig b/tinylinux/core.gz.orig deleted file mode 100644 index 4d1a163..0000000 Binary files a/tinylinux/core.gz.orig and /dev/null differ diff --git a/tinylinux/makeusb b/tinylinux/makeusb deleted file mode 100755 index dbd01cc..0000000 --- a/tinylinux/makeusb +++ /dev/null @@ -1,98 +0,0 @@ -#!/bin/bash -# create an USB stick with TinyLinux on it -# name of the USB stick to be created -BOOT_TINY_SRC=l_samenv@linse-c:boxes/boot_tiny -SSH_BOXES_SRC=l_samenv@linse-c:boxes/ssh_for_boxes - -[ "$EUID" -eq 0 ] || { echo "Please run as root"; exit 1; } - -# list removeable disks -DISKS=() -while read LINE -do - ARR=($LINE) - if [[ ${ARR[@]:0:2} == "1 disk" ]]; then - DISKS+=(${ARR[@]:2:1}) - printf "%-7s %7s " ${ARR[@]:2:2} - echo ${ARR[@]:4} - elif [[ ${ARR[@]:0:2} == "1 part" ]]; then - printf " %7s " ${ARR[@]:3:1} - echo ${ARR[@]:4} - fi -done < <(lsblk -l --output RM,TYPE,NAME,SIZE,LABEL,VENDOR,MODEL) - -echo "which device? should be one of: ${DISKS[@]}" -read DEVICE - -if [ -z $DEVICE ] ; then - exit -fi - -if [[ " ${DISKS[@]} " =~ " $DEVICE " ]]; then - if [[ $(cat /sys/block/$DEVICE/removable) != "1" ]]; then - echo "/dev/$DEVICE is not a removable disk" - exit - fi - - if [ -z "$1" ]; then - read -p "name for stick name [apu-boot]: " name - name=${name:-apu-boot} - else - name=$1 - fi - - stickname=${name//_/-} - stickname=${stickname,,} - label=${name//-/_} - label=${label^^} - - # allow only letters and digits - case "$stickname" in - *[!A-Za-z0-9-]*|.*) echo "invalid hostname '$stickname' (use letters, digits and dash only)"; exit 1 ;; - esac - - echo "create TinyLinux stick $label (host name $stickname)" - - rm -rf tmp - sudo --user l_samenv mkdir tmp - sudo --user l_samenv scp -r $BOOT_TINY_SRC tmp/ - sudo --user l_samenv scp -r $SSH_BOXES_SRC tmp/ - - STICKDIR=sticks/$stickname - if [ ! -d $STICKDIR ]; then - mkdir -p $STICKDIR - fi - bash build_core.sh $stickname - if [ ! -f $STICKDIR/core.gz ]; then - echo "no core.gz created -> build_core.sh failed" - exit - fi - sudo --user l_samenv cp $STICKDIR/core.gz tmp/boot_tiny/scripts/ - DEVICE=/dev/$DEVICE - - umount ${DEVICE}1 - dd if=/dev/zero of=${DEVICE} count=1 conv=notrunc - echo -e "o\nn\np\n1\n\n\nw" | fdisk ${DEVICE} - mkfs.vfat -n $label -I ${DEVICE}1 - - syslinux -i ${DEVICE}1 - dd conv=notrunc bs=440 count=1 if=tmp/boot_tiny/mbr.bin of=${DEVICE} - parted ${DEVICE} set 1 boot on - - mkdir -p /mnt/apusb - mount ${DEVICE}1 /mnt/apusb - echo "copy files ..." - cp -r tmp/boot_tiny/scripts/* /mnt/apusb/ - umount /mnt/apusb - - echo "done." - echo "--------------------------------------------------------------------" - echo "stick into a box, reboot and wait 2 minutes, then:" - echo "" - echo "nslookup $stickname" - echo "" - echo "if found ip start with 129.129., you can login as tc@$stickname" - echo "ip start with 10., the box has first to be registered to PacketFence" -else - echo "/dev/$DEVICE is not a removeable disk" -fi diff --git a/tinylinux/tcz/lz4.tcz b/tinylinux/tcz/lz4.tcz deleted file mode 100644 index 3715a9d..0000000 Binary files a/tinylinux/tcz/lz4.tcz and /dev/null differ diff --git a/tinylinux/tcz/lz4.tcz.md5.txt b/tinylinux/tcz/lz4.tcz.md5.txt deleted file mode 100644 index f34e031..0000000 --- a/tinylinux/tcz/lz4.tcz.md5.txt +++ /dev/null @@ -1 +0,0 @@ -9a994075cedcc853c448cc9691c3fe38 lz4.tcz diff --git a/tinylinux/tcz/nano.tcz b/tinylinux/tcz/nano.tcz deleted file mode 100644 index bd6186f..0000000 Binary files a/tinylinux/tcz/nano.tcz and /dev/null differ diff --git a/tinylinux/tcz/nano.tcz.dep b/tinylinux/tcz/nano.tcz.dep deleted file mode 100644 index 8ae0b07..0000000 --- a/tinylinux/tcz/nano.tcz.dep +++ /dev/null @@ -1 +0,0 @@ -ncurses.tcz diff --git a/tinylinux/tcz/nano.tcz.md5.txt b/tinylinux/tcz/nano.tcz.md5.txt deleted file mode 100644 index 595aa3c..0000000 --- a/tinylinux/tcz/nano.tcz.md5.txt +++ /dev/null @@ -1 +0,0 @@ -ce9cf3b540095da2f62d958d85a15e2e nano.tcz diff --git a/tinylinux/tcz/ncurses.tcz b/tinylinux/tcz/ncurses.tcz deleted file mode 100644 index d72d859..0000000 Binary files a/tinylinux/tcz/ncurses.tcz and /dev/null differ diff --git a/tinylinux/tcz/ncurses.tcz.md5.txt b/tinylinux/tcz/ncurses.tcz.md5.txt deleted file mode 100644 index b253652..0000000 --- a/tinylinux/tcz/ncurses.tcz.md5.txt +++ /dev/null @@ -1 +0,0 @@ -234b09001894df7f888a5905067c9be3 ncurses.tcz diff --git a/tinylinux/tcz/openssh.tcz b/tinylinux/tcz/openssh.tcz deleted file mode 100644 index 82b029d..0000000 Binary files a/tinylinux/tcz/openssh.tcz and /dev/null differ diff --git a/tinylinux/tcz/openssh.tcz.dep b/tinylinux/tcz/openssh.tcz.dep deleted file mode 100644 index 8c212df..0000000 --- a/tinylinux/tcz/openssh.tcz.dep +++ /dev/null @@ -1,2 +0,0 @@ -openssl.tcz - diff --git a/tinylinux/tcz/openssh.tcz.md5.txt b/tinylinux/tcz/openssh.tcz.md5.txt deleted file mode 100644 index 575c779..0000000 --- a/tinylinux/tcz/openssh.tcz.md5.txt +++ /dev/null @@ -1 +0,0 @@ -ad59211499d2b35c624b85eaec4ce53a openssh.tcz diff --git a/tinylinux/tcz/openssl.tcz b/tinylinux/tcz/openssl.tcz deleted file mode 100644 index 500ed70..0000000 Binary files a/tinylinux/tcz/openssl.tcz and /dev/null differ diff --git a/tinylinux/tcz/openssl.tcz.md5.txt b/tinylinux/tcz/openssl.tcz.md5.txt deleted file mode 100644 index 9abc2dc..0000000 --- a/tinylinux/tcz/openssl.tcz.md5.txt +++ /dev/null @@ -1 +0,0 @@ -e7bfb084e3fbab7eae0a2a0f2cdef0ff openssl.tcz