Skip to content

Commit

Permalink
Merge pull request nightscout#20 from Navid200/VerifyVM
Browse files Browse the repository at this point in the history
Verify Virtual Machine
  • Loading branch information
jamorham authored Nov 11, 2022
2 parents 6e1ef95 + b068ea0 commit 0b38aac
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 40 deletions.
81 changes: 60 additions & 21 deletions Status.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,65 @@
#!/bin/bash

# Show a summary of parameters. - Navid200
clear
echo "Please be patient (30 seconds)"
echo " "
echo " "

cd /tmp
echo " Developed by the xDrip team " > tmp
echo " " >> tmp
echo "--------------------------------------------------" >> tmp
lsb_release -a | sed -n 2p >> tmp
echo " " >> tmp
echo "--------------------------------------------------" >> tmp
free -h | sed -n 3p >> tmp
echo " " >> tmp
echo "--------------------------------------------------" >> tmp
df -m . >> tmp
echo " " >> tmp
echo "--------------------------------------------------" >> tmp
echo "MongoDB" >> tmp
mongod --version | sed -n 1p >> tmp
echo " " >> tmp
echo "--------------------------------------------------" >> tmp
echo "Nightscout process" >> tmp
ps -ef | grep SCREEN | grep root | fold --width=40 | sed -n 1p >> tmp

dialog --colors --textbox tmp 25 50
Ram=$(free -m | sed -n 2p | awk '{print $2}')
unit="M"
Ramsize="$Ram"$unit
if [ $Ram -gt 1000 ]
then
Ramsize="\Zb\Z1 $Ram$unit \Zn"
fi

disk="\Z1\ZbBalanced\Zn"
if [ $(cat /sys/block/sda/queue/rotational) -eq 1 ]
then
disk="Standard"
fi

disksz="$(df -h | sed -n 2p | awk '{print $2}')"
if [ ! "$disksz" = "29G" ]
then
disksz="\Zb\Z1$(df -h | sed -n 2p | awk '{print $2}')\Zn"
fi

swap="$(free -h | sed -n 3p | awk '{print $2}')"

ubuntu="$(lsb_release -a | sed -n 2p | awk '{print $3, $4}')"
if [ ! "$ubuntu" = "20.04.5 LTS" ]
then
ubuntu="\Zb\Z1$(lsb_release -a | sed -n 2p | awk '{print $3, $4}')\Zn"
fi

current=$(wget -q -O - http://checkip.dyndns.org|sed s/[^0-9.]//g)
nc -zvw10 $current 80 2> /tmp/http
grep 'timed out' /tmp/http > /tmp/http2
nc -zvw10 $current 443 2> /tmp/https
grep 'timed out' /tmp/https > /tmp/https2
http="Open"
if [ -s /tmp/http2 ] || [ -s /tmp/https2 ]
then
http="\Zb\Z1Closed\Zn"
fi


mongo="$(mongod --version | sed -n 1p)"
ns="$(ps -ef | grep SCREEN | grep root | fold --width=40 | sed -n 1p)"

dialog --colors --msgbox " \Zr Developed by the xDrip team \Zn\n\n\
\Zb Status \Zn \n\\n
\ZbVirtual Machine\Zn \n\
RAM: $Ramsize \n\
Disk type: "$disk" \n\
Disk size: $disksz \n\
Ubuntu: $ubuntu \n\
HTTP & HTTPS: $http \n\n\
------------------------------------------ \n\
Swap: $swap \n\
Mongo: $mongo \n\
NS proc: $ns \n\
" 21 50

44 changes: 28 additions & 16 deletions bootstrap.sh
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
#!/bin/sh
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin"

# curl https://raw.githubusercontent.com/Navid200/cgm-remote-monitor/Navid_2022_10_26Test/bootstrap.sh | bash
# curl https://raw.githubusercontent.com/Navid200/cgm-remote-monitor/VerifyVM_Test/bootstrap.sh | bash <--- Only tested this way

echo
echo "Bootstrapping the menu - Navid200"
echo

sudo apt-get update
sudo apt-get install dialog
ubversion="$(cat /etc/issue | awk '{print $2}')"
if [[ ! "$ubversion" = "20.04"* ]]
then
clear
dialog --colors --msgbox " \Zr Developed by the xDrip team \Zn\n\n\
The Ubuntu version on the virtual machine is incorrect. You need to delete the virtual machine and create a new one. Please refer to the guide for the details." 10 50
exit
fi

sudo apt-get -y install wget bash
sudo apt-get -y install dialog
sudo apt-get install -y git python gcc g++ make

cd /tmp
clear
dialog --msgbox "Shortly after you proceed, the server will\n\
automatically reboot and an expected error\n\
message will appear.\n\
Please wait 30 seconds before clicking on\n\
"Retry" to reconnect.\n\n\
After this, every time you open a terminal,\n\
a menu will offer all the available options.\n\n\
To proceed, press Enter." 15 48
clear
sudo apt-get -y install netcat

cd /
if [ ! -s xDrip ]
Expand All @@ -37,7 +35,7 @@ fi

cd /tmp
sudo rm update_scripts.sh
#wget https://raw.githubusercontent.com/Navid200/cgm-remote-monitor/Navid_2022_10_26Test/update_scripts.sh # Navid's
#wget https://raw.githubusercontent.com/Navid200/cgm-remote-monitor/VerifyVM_Test/update_scripts.sh # Navid's
wget https://raw.githubusercontent.com/jamorham/nightscout-vps/vps-1/update_scripts.sh # Main
if [ ! -s update_scripts.sh ]
then
Expand All @@ -49,6 +47,11 @@ sudo chmod 755 update_scripts.sh
sudo mv -f update_scripts.sh /xDrip/scripts

# Updating the scripts
cat > /tmp/nodialog_update_scripts << EOF
Don't show dialog
EOF

sudo /xDrip/scripts/update_scripts.sh

# So that the menu comes up as soon as the user logs in (opens a terminal)
Expand All @@ -70,5 +73,14 @@ alias menu="/xDrip/scripts/menu.sh"
EOF
fi

# Reboot
clear
dialog --colors --msgbox " \Zr Developed by the xDrip team \Zn\n\n\
If any item is shown in red on the status page (shown next), it represents an incorrect parameter that could result in malfunction or cost. \
Please take a note, delete the virtual machine, and create a new one. For more detail, please refer to the guide." 12 50

# Bring up the status page
/xDrip/scripts/Status.sh
dialog --colors --msgbox " \Zr Developed by the xDrip team \Zn\n\n\
Press enter to restart the server. This will result in an expected error message. Wait 30 seconds before clicking on retry to reconnect." 10 50
sudo reboot

9 changes: 6 additions & 3 deletions update_scripts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,18 @@ sudo git clone https://github.com/jamorham/nightscout-vps.git # Clone the instal
cd nightscout-vps # Main
#cd cgm-remote-monitor # Navid's
sudo git checkout vps-1 # Main
#sudo git checkout Navid_2022_10_26Test # Navid's
#sudo git checkout VerifyVM_Test # Navid's
sudo git pull
sudo chmod 755 *.sh # Change premissions to allow execution by all.
sudo mv -f *.sh /xDrip/scripts # Overwrite the scripts in the scripts directory with the new ones.
cd ..
sudo rm -r nightscout-vps # Delete the temporary pull directory. # Main
#sudo rm -r cgm-remote-monitor # Delete the temporary pull directory. # Navid's

dialog --msgbox "In a new, or restored, terminal,\n\
the updated scripts will be in effect." 7 43
if [ ! -s /tmp/nodialog_update_scripts ]
then
dialog --colors --msgbox " \Zr Developed by the xDrip team \Zn\n\n\
Updated scripts will be in effect in a new window." 8 43
clear
fi

0 comments on commit 0b38aac

Please sign in to comment.