123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- #!/bin/bash
- Version=`cat build_node.sh | grep -Po "(?<=Version=)([0-9]|\.)*(?=\s|$)"`
- echo -e "\e[93mLitecoincash Headless Node builder $Version USB Tool\e[0m"
- echo -e "Author : wareck@gmail.com"
- f2fs_="NO" # add YES for f2fs, NO for ext4
- sda=""
- sdb=""
- sdc=""
- sdd=""
- sda=`ls -n /dev/disk/by-uuid/ | grep "sda" | awk '{print$9}'` >/dev/null
- sdb=`ls -n /dev/disk/by-uuid/ | grep "sdb" | awk '{print$9}'` >/dev/null
- sdc=`ls -n /dev/disk/by-uuid/ | grep "sdc" | awk '{print$9}'` >/dev/null
- sdd=`ls -n /dev/disk/by-uuid/ | grep "sdd" | awk '{print$9}'` >/dev/null
- function error_config {
- echo -e "\nChoose your file filesystem first:"
- echo "nano usb.sh"
- echo "edit f2fs=\"YES\" for f2fs or f2fs=\"NO\" for ext4"
- echo "save and run again ./usb.sh"
- echo ""
- exit
- }
- if [ -z $f2fs_ ]; then error_config && exit ;fi
- if ! [[ $f2fs_ = "YES" || $f2fs_ = "NO" ]]
- then
- echo $f2fs_
- error_config
- fi
- if [ -z $sda ];then sda_p=0; else sda_p=1;fi
- if [ -z $sdb ];then sdb_p=0; else sdb_p=1;fi
- if [ -z $sdc ];then sdc_p=0; else sdc_p=1;fi
- if [ -z $sdd ];then sdd_p=0; else sdd_p=1;fi
- num=$(($sda_p + $sdb_p + $sdc_p + $sdd_p))
- echo ""
- if ! [ $num = 1 ]
- then
- echo -e "More than one USB drive."
- echo -e "\e[33mCan't continue automaticaly\e[0m."
- echo -e "Please remove one USB drive or do it manualy..."
- echo -e
- exit
- else
- echo -e "Drive detected => \e[32mUUID=$sda\e[0m"
- fi
- if ! grep -q $sda /etc/fstab
- then
- if [ -f /tmp/tmp ]; then rm /tmp/tmp ;fi
- if [ $f2fs_ = "YES" ]
- then
- sudo apt-get install f2fs-tools -y
- cat <<'EOF'>> /tmp/tmp
- #USB Drive for OkCash
- UUID=SDA /home/pi/.litecoincash f2fs defaults,noatime 0 1
- EOF
- else
- cat <<'EOF'>> /tmp/tmp
- #USB Drive for OkCash
- UUID=SDA /home/pi/.litecoincash ext4 defaults,noatime 0 1
- EOF
- fi
- sed -i "s/SDA/$sda/" /tmp/tmp
- sed -i "s/pi/$USER/" /tmp/tmp
- sudo bash -c "cat /tmp/tmp >> /etc/fstab"
- echo -e "\n\e[95mLines added to /etc/fstab:\e[0m"
- tail -n +2 /tmp/tmp
- echo -e ""
- sleep 2
- else
- echo -e ""
- echo -e "Drive is already defined in /etc/fstab."
- echo -e ""
- sleep 1
- fi
- if [ ! -d /home/$USER/.litecoincash ]
- then
- echo -e "\e[95mCreate directory:\e[0m"
- echo -e "mkdir /home/$USER/.litecoincash"
- mkdir /home/$USER/.litecoincash
- sudo chown -R $USER /home/$USER/.litecoincash
- sudo chmod -R 777 /home/$USER/.litecoincash
- echo -e "Done."
- echo -e
- fi
- echo -e "\e[95mMount drive:\e[0m"
- sudo chown -R $USER /home/$USER/.litecoincash
- sudo chmod -R 777 /home/$USER/.litecoincash
- if mountpoint -q "/home/$USER/.litecoincash"
- then
- echo -e "Already mounted."
- echo -e "Done."
- echo -e
- else
- sudo mount /home/$USER/.litecoincash
- echo "Done."
- echo -e
- fi
- echo -e "\e[95mDirectory Check:\e[0m"
- ls -w 2 /home/$USER/.litecoincash
- echo -e
|