-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automatic pipe creation using scripts
- Loading branch information
1 parent
3f48023
commit 77aaad4
Showing
9 changed files
with
188 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,8 @@ install_bins: | |
chmod +x /usr/local/bin/get-free-space | ||
chmod +x /usr/local/bin/mount-unmount-usb | ||
chmod +x /usr/local/bin/get-reflash-version | ||
chmod +x /usr/local/bin/flash-cleanup | ||
chmod +x /usr/local/bin/flash-mkfifo | ||
|
||
upload_bins: | ||
scp bin/prod/* [email protected]:/usr/local/bin | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
info() { | ||
echo "[info] $1" >> /var/log/reflash.log | ||
echo "$1" | ||
} | ||
|
||
info "-----------------------" | ||
info "Starting cleanup script" | ||
info "-----------------------" | ||
|
||
REVISION=$1 | ||
OUTFILE="/opt/reflash/mmcblk2" | ||
|
||
info "Using Recore hardware revision $REVISION" | ||
info "Overwriting block device $OUTFILE" | ||
info "Checking filesystems" | ||
info "Creating new UUIDs" | ||
info "Cleanup script done!" |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
info() { | ||
echo "[info] $1" >> /var/log/reflash.log | ||
echo "$1" | ||
} | ||
|
||
info "-----------------------" | ||
info "Starting mkfifo script" | ||
info "-----------------------" | ||
|
||
OUTFILE="/opt/reflash/mmcblk2" | ||
FIFO="/tmp/mypipe" | ||
|
||
info "Overwriting block device $OUTFILE" | ||
|
||
rm -f "$FIFO" | ||
mkfifo "$FIFO" | ||
xz -d < "$FIFO" > "$OUTFILE" & | ||
|
||
info "Mkfifo script done!" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
info() { | ||
echo "[info] $1" >> /var/log/reflash.log | ||
echo "$1" | ||
} | ||
|
||
info "-----------------------" | ||
info "Starting cleanup script" | ||
info "-----------------------" | ||
|
||
REVISION=$1 | ||
OUTFILE="/dev/mmcblk2" | ||
|
||
info "Using Recore hardware revision $REVISION" | ||
info "Overwriting block device $OUTFILE" | ||
|
||
sync | ||
|
||
# Re-read partition table | ||
partprobe ${OUTFILE} | ||
|
||
info "Checking filesystems" | ||
e2fsck -y -f ${OUTFILE}p1 | ||
e2fsck -y -f ${OUTFILE}p2 | ||
|
||
# Create new uuids so they are different than the USB drive | ||
info "Creating new UUIDs" | ||
tune2fs -U random ${OUTFILE}p1 | ||
tune2fs -U random ${OUTFILE}p2 | ||
|
||
UUID1=$(blkid -s UUID -o value ${OUTFILE}p1) | ||
UUID2=$(blkid -s UUID -o value ${OUTFILE}p2) | ||
|
||
mkdir -p /mnt/emmc | ||
# mount and exchange UUID | ||
mount ${OUTFILE}p2 /mnt/emmc | ||
info "Updating fstab with new UUIDs" | ||
sed -i "s:UUID=.* \/ :UUID=${UUID2} / :" /mnt/emmc/etc/fstab | ||
sed -i "s:UUID=.* \/boot :UUID=${UUID1} /boot :" /mnt/emmc/etc/fstab | ||
|
||
# Copy config file, if one is not already present | ||
if test -d /mnt/emmc/home/debian; then | ||
cd /mnt/emmc/home/debian/ || exit | ||
if ! test -f printer_data/config/printer.cfg; then | ||
if test -f klipper/config/generic-recore-"$REVISION".cfg; then | ||
info "Installing Klipper config file" | ||
cp klipper/config/generic-recore-"$REVISION".cfg printer_data/config/printer.cfg | ||
chown 1000:1000 printer_data/config/printer.cfg | ||
fi | ||
# Enable mainsail on mainsail distros | ||
if test -f printer_data/config/mainsail.cfg; then | ||
info "Including Mainsail in config file, above the first section" | ||
# Older distros has the include fiel as a comment | ||
sed -i 's/\#\[include mainsail.cfg\]//' printer_data/config/printer.cfg | ||
sed -i 's:\(\[recore.*\]\):\[include mainsail.cfg\]\n\n\1:' printer_data/config/printer.cfg | ||
fi | ||
# Enable fluidd on fluidd distros | ||
if test -f printer_data/config/fluidd.cfg; then | ||
info "Including Fluidd in config file, above the first section" | ||
# Older distros has the include fiel as a comment | ||
sed -i 's/\#\[include mainsail.cfg\]//' printer_data/config/printer.cfg | ||
sed -i 's:\(\[recore.*\]\):\[include fluidd.cfg\]\n\n\1:' printer_data/config/printer.cfg | ||
fi | ||
fi | ||
fi | ||
cd / | ||
umount ${OUTFILE}p2 | ||
|
||
mount ${OUTFILE}p1 /mnt/emmc | ||
sed -i "/^rootdev=.*/d" /mnt/emmc/armbianEnv.txt | ||
sed -i '/^$/d' /mnt/emmc/armbianEnv.txt | ||
echo "rootdev=UUID=${UUID2}" >> /mnt/emmc/armbianEnv.txt | ||
|
||
cd /mnt/emmc/dtb/allwinner/ || exit | ||
if test -f sun50i-a64-recore-"$REVISION".dtb; then | ||
info "Symlinking device tree" | ||
ln -sf sun50i-a64-recore-"$REVISION".dtb sun50i-a64-recore.dtb | ||
fi | ||
cd / | ||
umount ${OUTFILE}p1 | ||
|
||
sync | ||
info "Cleanup script done!" |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
info() { | ||
echo "[info] $1" >> /var/log/reflash.log | ||
echo "$1" | ||
} | ||
|
||
info "-----------------------" | ||
info "Starting mkfifo script" | ||
info "-----------------------" | ||
|
||
OUTFILE="/dev/mmcblk2" | ||
FIFO="/tmp/mypipe" | ||
|
||
info "Overwriting block device $OUTFILE" | ||
|
||
rm -f "$FIFO" | ||
mkfifo "$FIFO" | ||
xz -d < "$FIFO" > "$OUTFILE" & | ||
|
||
info "Mkfifo script done!" |
This file contains 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
This file contains 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