sending works

Szymon Karpiński 7 years ago
parent 739ce24c47
commit 248c1f033b
  1. 1
      .gitignore
  2. 4
      Makefile
  3. 13
      linux/Makefile
  4. 11
      linux/src/scripts/menu.sh
  5. 6
      linux/src/scripts/send_dd.sh
  6. 6
      linux/src/scripts/send_pc.sh
  7. 6
      linux/src/scripts/send_sfd.sh
  8. 2
      pxelinux.cfg
  9. 4
      receive.sh

1
.gitignore vendored

@ -1,2 +1,3 @@
linux/build/ linux/build/
syslinux/ syslinux/
files/

@ -1,3 +1,5 @@
.PHONY: .FORCE
files: files/pxelinux.0 files/initrd.img files/vmlinuz files/pxelinux.cfg/default files/ldlinux.c32 files/root.squashfs files: files/pxelinux.0 files/initrd.img files/vmlinuz files/pxelinux.cfg/default files/ldlinux.c32 files/root.squashfs
files/pxelinux.0: syslinux files/pxelinux.0: syslinux
@ -16,7 +18,7 @@ files/pxelinux.cfg/default: pxelinux.cfg
files/ldlinux.c32: syslinux files/ldlinux.c32: syslinux
cp syslinux/bios/com32/elflink/ldlinux/ldlinux.c32 files/ldlinux.c32 cp syslinux/bios/com32/elflink/ldlinux/ldlinux.c32 files/ldlinux.c32
files/root.squashfs: linux/build/rootfs files/root.squashfs: .FORCE
rm files/root.squashfs || true rm files/root.squashfs || true
mksquashfs linux/build/rootfs files/root.squashfs mksquashfs linux/build/rootfs files/root.squashfs

@ -3,22 +3,29 @@ CHROOT_CMD := chroot build/rootfs /bin/bash -c
FILES = $(shell find src/ -type f -print | sed -e 's|^src/|build/rootfs/|') FILES = $(shell find src/ -type f -print | sed -e 's|^src/|build/rootfs/|')
FILES_SRC = $(shell find src/ -type f -print) FILES_SRC = $(shell find src/ -type f -print)
all: build/rootfs $(FILES) menu build/rootfs/initrd.img .PHONY: .FORCE
all: build/rootfs $(FILES) menu images build/rootfs/initrd.img
clean: clean:
rm -rf build/rootfs rm -rf build/rootfs
menu: $(FILES) menu:
$(CHROOT_CMD) "apt install dialog" $(CHROOT_CMD) "apt install dialog"
$(CHROOT_CMD) "chmod +x /scripts/menu.sh" $(CHROOT_CMD) "chmod +x /scripts/menu.sh"
$(CHROOT_CMD) "usermod -s /scripts/menu.sh root" $(CHROOT_CMD) "usermod -s /scripts/menu.sh root"
images:
$(CHROOT_CMD) "apt install -y udpcast"
$(CHROOT_CMD) "apt install -y partclone"
$(CHROOT_CMD) "apt install -y lzop"
build/rootfs/initrd.img: $(FILES) build/rootfs/initrd.img: $(FILES)
chmod +x build/rootfs/etc/initramfs-tools/scripts/local-top/download.sh chmod +x build/rootfs/etc/initramfs-tools/scripts/local-top/download.sh
$(CHROOT_CMD) "apt update && apt install -y linux-image-4.19.0-6-amd64" $(CHROOT_CMD) "apt update && apt install -y linux-image-4.19.0-6-amd64"
$(CHROOT_CMD) "update-initramfs -c -kall" $(CHROOT_CMD) "update-initramfs -c -kall"
$(FILES): $(FILES_SRC) $(FILES): .FORCE
mkdir -p $(@D) mkdir -p $(@D)
cp $(shell echo $@ | sed -e 's|^build/rootfs/|src/|') $@ cp $(shell echo $@ | sed -e 's|^build/rootfs/|src/|') $@

@ -2,13 +2,12 @@
sleep 1 sleep 1
dialog --menu " " 10 80 5 \ dialog --menu " " 20 80 10 \
recv_fsa "Receive and write fsarchiver's archive (to /dev/sda1)" \ send_pc "Send /dev/sda1 image (partclone)" \
recv_sfd "Receive and write sfdisk's partition table" \ send_sfd "Send /dev/sda partition table (sfdisk)" \
shell "Run root shell" 2>/tmp/menu \ send_dd "Send /dev/sda MBR (dd)" \
shell "Run root shell" 2>/tmp/menu
if [ "$?" != "0" ]; then CHOICE="shell"; else CHOICE=$(cat /tmp/menu); fi if [ "$?" != "0" ]; then CHOICE="shell"; else CHOICE=$(cat /tmp/menu); fi
if ! [ -f "$CHOICE" ]; then CHOICE="shell"; fi
bash $(dirname "$0")/$CHOICE.sh bash $(dirname "$0")/$CHOICE.sh

@ -0,0 +1,6 @@
#!/bin/bash
DISK=/dev/sda
INTERFACE=eth0
dd if=$DISK bs=512 count=1 | udp-sender --interface $INTERFACE

@ -0,0 +1,6 @@
#!/bin/bash
DISK=/dev/sda1
INTERFACE=eth0
partclone.extfs -s /dev/sda1 -c --logfile /tmp/partclone.log 2>/dev/null| lzop | udp-sender --interface $INTERFACE

@ -0,0 +1,6 @@
#!/bin/bash
DISK=/dev/sda
INTERFACE=eth0
sfdisk -d $DISK | udp-sender --interface $INTERFACE

@ -2,6 +2,6 @@ DEFAULT linux
LABEL linux LABEL linux
kernel vmlinuz kernel vmlinuz
append initrd=initrd.img root=/dev/loop0 append initrd=initrd.img root=/dev/loop0 net.ifnames=0 biosdevname=0
PROMPT 0 PROMPT 0
TIIMEOUT 0 TIIMEOUT 0

@ -0,0 +1,4 @@
#!/bin/bash
INTERFACE=$1
udp-receiver --interface $INTERFACE
Loading…
Cancel
Save