diff --git a/clone/clone b/clone/clone index 2138217..12ab2f3 100755 --- a/clone/clone +++ b/clone/clone @@ -25,8 +25,9 @@ fi # (2) Check USB and not a hard drive !!!!!!!!!! # device_type=$(udevadm info --query=all -n $1 | grep -E "ID_BUS" | awk '{print $2}' | sed 's/ID_BUS=//'); +device_type_pt1=$(udevadm info --query=all -n $11 | grep -E "ID_BUS" | awk '{print $2}' | sed 's/ID_BUS=//'); -if [ "$device_type" != "usb" ]; then +if [ "$device_type" != "usb" -a "$device_type_pt1" != "usb" ]; then echo ">>> ERROR: device type is $device_type, \"usb\" expected."; exit 1; fi; @@ -63,7 +64,7 @@ step1(){ for mounted in $mounted_partitions; do - read -p " (!) umount $mounted (y/n) [n]" unmount; + read -n 1 -p " (!) umount $mounted (y/n) [n]" unmount; if [ -n "$unmount" ] && [ $unmount = "y" ]; then sudo umount $mounted 2> /dev/null > /dev/null \ @@ -88,7 +89,7 @@ step2(){ echo -e "\n>>> [2] Formatting disk ($DEV)"; # (1) Confirmation # - read -p" (!) Erase the whole disk ? it is irreversible! (y/n) [n]" confirm_format; + read -n 1 -p " (!) Erase the whole disk ? it is irreversible! (y/n) [n]" confirm_format; if [ -z "$confirm_format" ]; then echo "<<< aborting"; exit 1; @@ -119,7 +120,7 @@ step3(){ echo -e "\n>>> [3] Burning image into disk ($DEV)"; # (1) Confirmation # - read -p" (!) Burn the whole disk ? it is irreversible! (y/n) [n]" confirm_burn; + read -n 1 -p " (!) Burn the whole disk ? it is irreversible! (y/n) [n]" confirm_burn; if [ -z "$confirm_burn" ]; then echo "<<< aborting"; exit 1; @@ -135,21 +136,25 @@ step3(){ if [ "$IMAGE_GZIP" = "1" ]; then - echo " - using gunzip"; + echo " - burning proccess (gunzip) ..." - ( sudo dd if=$IMAGE_FILE of=$DEV bs=4M status=progress ) \ - || echo "<<< error: dd command failed" || exit 1; + ( sudo dd if=$IMAGE_FILE of=$DEV bs=1M status=progress ) \ + && echo " > burnt" \ + || ( echo "<<< error: dd command failed"; exit 1 ) || exit 1; else - ( sudo dd if=$IMAGE_FILE of=$DEV bs=4M status=progress ) \ - || echo "<<< error: dd command failed" || exit 1; + echo " - burning proccess ..."; + + ( sudo dd if=$IMAGE_FILE of=$DEV bs=1M status=progress ) \ + && echo " > burnt" \ + || ( echo "<<< error: dd command failed"; exit 1 ) || exit 1; fi; - echo " - emptying memory buffers to disk"; - sync; + echo " - writing memory buffers to disk"; + sudo sync $DEV; echo "<<< done"; @@ -250,7 +255,7 @@ step6(){ # (1) Create ssh key pair # echo " (.) Create ssh key [ecdsa:521]"; - ssh-keygen -t ecdsa -b 521 -C "[ECDSA:521] SATS@$MACHINE_ID" -f ./tmp/id_ecdsa -P "" 2> /dev/null > /dev/null; + ssh-keygen -t ecdsa -b 521 -C "[ECDSA:521] SATS@$MACHINE_ID" -f ./tmp/id_ecdsa -P ""; # 2> /dev/null > /dev/null; # (2) Add public key to server's `authorized_keys` file # echo " (.) Add public key to server's list"; @@ -411,7 +416,7 @@ step7(){ sudo ln -fs /lib/systemd/system/sats-sync-stop.path /mnt/etc/systemd/system/multi-user.target.wants/sats-sync-stop.path; # (6) Enable sats-dwc@wlan0 at startup # - echo " (.) Emulate \`systemctl enable sats-dwc@wlan0.service\`"; + echo " (.) Emulate \`systemctl enable sats-dwc@$WIFI_DEVICE.service\`"; sudo ln -fs /lib/systemd/system/sats-dwc@.service /mnt/etc/systemd/system/multi-user.target.wants/sats-dwc@$WIFI_DEVICE.service; # (7) Enable firewall@default at startup # @@ -442,8 +447,8 @@ step7(){ cat ./utility/sats-sync-stop | sudo tee /mnt/service/sats-sync-stop > /dev/null; # (6) Create sats-dwc@wlan0 script # - echo " (.) Create sats-dwc@wlan0 script"; - cat ./utility/wlan0.dwc | sed "s/\*\*\*SALT\*\*\*/$WIFI_SALT/" | sed "s/\*\*\*PEPPER\*\*\*/$WIFI_PEPPER/" | sudo tee /mnt/etc/wpa_supplicant/$WIFI_DEVICE.dwc > /dev/null; + echo " (.) Create sats-dwc@$WIFI_DEVICE script"; + cat ./utility/wireless.dwc | sed "s/\*\*\*SALT\*\*\*/$WIFI_SALT/" | sed "s/\*\*\*PEPPER\*\*\*/$WIFI_PEPPER/" | sudo tee /mnt/etc/wpa_supplicant/$WIFI_DEVICE.dwc > /dev/null; # (7) Create firewall@default script # echo " (.) Create firewall@default script"; diff --git a/clone/clone.conf b/clone/clone.conf index 85e1344..6071bb2 100755 --- a/clone/clone.conf +++ b/clone/clone.conf @@ -22,4 +22,4 @@ export MACHINE_SECRET=$(tr -dc A-Za-z0-9_ < /dev/urandom | head -c 250); export NEXT_SECRET=$(tr -dc A-Za-z0-9_ < /dev/urandom | head -c 250); export UNLOCK_CODE=$(tr -dc a-f0-9 < /dev/urandom | head -c 128); export WAREHOUSE_TOKEN="52131065a906de90e26da0732e58400edd6739cfa03fc658e7593abef4a4504e18e66e1a8fe9da374a8e8f753603463e4777789262b3ee945d4bf72dd8d6399c"; -f \ No newline at end of file +