Skip to content

Commit

Permalink
Merge pull request nightscout#24 from Navid200/Navid_2022_11_16
Browse files Browse the repository at this point in the history
FreeDNS
  • Loading branch information
jamorham authored Nov 19, 2022
2 parents 0b38aac + 529f991 commit 85ce635
Show file tree
Hide file tree
Showing 29 changed files with 1,139 additions and 1,554 deletions.
65 changes: 31 additions & 34 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x, 14.x]
node-version: [12.x, 14.x, 16.x]
mongodb-version: [4.2, 4.4]

steps:
Expand All @@ -40,14 +40,19 @@ jobs:
- name: Send Coverage
run: npm run-script coverage

publish_dev:
name: Publish dev branch to Docker Hub
publish:
name: Publish to Docker Hub
needs: test
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/dev' && github.repository_owner == 'nightscout'
if: (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev') && github.repository_owner == 'nightscout'
env:
DOCKER_IMAGE: nightscout/cgm-remote-monitor
PLATFORMS: linux/amd64,linux/arm64
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
Expand All @@ -57,37 +62,29 @@ jobs:
if: success()
uses: actions/checkout@v2
- name: Build, tag and push the dev Docker image
if: success()
run: |
docker build --no-cache=true -t ${{ env.DOCKER_IMAGE }}:dev_${{ github.sha }} .
docker image push ${{ env.DOCKER_IMAGE }}:dev_${{ github.sha }}
docker tag ${{ env.DOCKER_IMAGE }}:dev_${{ github.sha }} ${{ env.DOCKER_IMAGE }}:latest_dev
docker image push ${{ env.DOCKER_IMAGE }}:latest_dev
publish_master:
name: Publish master branch to Docker Hub
needs: test
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master' && github.repository_owner == 'nightscout'
env:
DOCKER_IMAGE: nightscout/cgm-remote-monitor
steps:
- name: Login to Docker Hub
uses: docker/login-action@v1
if: success() && github.ref == 'refs/heads/dev'
uses: docker/build-push-action@v2
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}
- name: Clean git Checkout
if: success()
uses: actions/checkout@v2
- name: get-npm-version
if: success()
context: .
push: true
no-cache: true
platforms: ${{ env.PLATFORMS }}
tags: |
${{ env.DOCKER_IMAGE }}:dev_${{ github.sha }}
${{ env.DOCKER_IMAGE }}:latest_dev
- name: Get Nightscout release version
if: success() && github.ref == 'refs/heads/master'
id: package-version
uses: martinbeentjes/npm-get-version-action@master
- name: Build, tag and push the master Docker image
if: success()
run: |
docker build --no-cache=true -t ${{ env.DOCKER_IMAGE }}:${{ steps.package-version.outputs.current-version }} .
docker image push ${{ env.DOCKER_IMAGE }}:${{ steps.package-version.outputs.current-version }}
docker tag ${{ env.DOCKER_IMAGE }}:${{ steps.package-version.outputs.current-version }} ${{ env.DOCKER_IMAGE }}:latest
docker image push ${{ env.DOCKER_IMAGE }}:latest
if: success() && github.ref == 'refs/heads/master'
uses: docker/build-push-action@v2
with:
context: .
push: true
no-cache: true
platforms: ${{ env.PLATFORMS }}
tags: |
${{ env.DOCKER_IMAGE }}:${{ steps.package-version.outputs.current-version }}
${{ env.DOCKER_IMAGE }}:latest
33 changes: 27 additions & 6 deletions ConfigServer/run_server_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,35 @@ exit 5
fi


# This function kills the exiting server if it exists so that it will not interfeer with the port
function kill_existing_server() {
sudo ps -ef | grep python3.*3389 | grep -v grep | awk '{print $2}' | \
while read -r pid ; do
sudo kill -9 "$pid";
done
}

kill_existing_server


export SECRET_KEY=$(uuidgen)
export ENV_DEBUG=False
export ENV_TOKEN=$(uuidgen)
export NS_CONFIG_FILE=/etc/nsconfig
export SCRIPT_DIR=$( dirname -- "$0"; )


sudo apt-get -y install python3-pip
pip install Django
pip install django-extensions Werkzeug
pip install qrcode

sudo apt-get -y install python3-pip >> /tmp/variables_log 2>&1
pip install Django django-extensions Werkzeug qrcode >> /tmp/variables_log 2>&1

if test -f "/etc/free-dns.sh"; then
. /etc/free-dns.sh
python3 manage.py migrate >> /tmp/variables_log 2>&1
else
export HOSTNAME=$(ls /etc/letsencrypt/live | grep -v README)
fi

python3 $SCRIPT_DIR/manage.py migrate >> /tmp/variables_log 2>&1

#make sure to put this after the migrate, as the migrate might fail.
export KILL_AFTER_IDLE_TIME=900
Expand All @@ -31,4 +48,8 @@ echo "The server will run for 15 minutes, and after that will stop (if not used)
echo

#python3 manage.py runserver 0.0.0.0:3389 >> /tmp/variables_log 2>&1
python3 manage.py runserver_plus 0.0.0.0:3389 --cert-file $CERT_LOCATION/cert.pem --key-file $CERT_LOCATION/privkey.pem >> /tmp/variables_log 2>&1
python3 $SCRIPT_DIR/manage.py runserver_plus 0.0.0.0:3389 --cert-file $CERT_LOCATION/cert.pem --key-file $CERT_LOCATION/privkey.pem >> /tmp/variables_log 2>&1 &

echo press any key to return to the menu. The server will continue to run for 15 minutes until stoped.
read

15 changes: 13 additions & 2 deletions ConfigureFreedns.sh
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,10 @@ if ! grep -q "DIRECTURL" /etc/rc.local; then
echo wget -O /tmp/freedns.txt --retry-connrefused --waitretry=1 --read-timeout=20 --timeout=15 \$DIRECTURL >> /etc/rc.local
fi

dialog --colors --msgbox " \Zr Developed by the xDrip team \Zn\n\n\
Press enter to proceed. Please be patient as it may take up to 10 minutes to complete." 8 50
clear
# wait for the ip to be updated. This might take up to 10 minutes.

cnt=0
while : ; do
sleep 30
Expand All @@ -175,5 +177,14 @@ while : ; do
done

#Fix the certificate using the new host name.
sudo certbot --nginx -d "$hostname" --redirect
sudo certbot --nginx -d "$hostname" --redirect --agree-tos --no-eff-email

if [ ! -s /etc/letsencrypt/live/"$hostname"/cert.pem ] || [ ! -s /etc/letsencrypt/live/"$hostname"/privkey.pem ]
then
cat > /tmp/FreeDNS_Failed << EOF
Internal error. Must run FreeDNS again.
EOF

dialog --colors --msgbox " \Zr Developed by the xDrip team \Zn\n\nInternal error. Press enter to exit. Then, run FreeDNS Setup again" 9 50
fi

31 changes: 22 additions & 9 deletions NS_Install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,28 @@ echo

if [ "`id -u`" != "0" ]
then
echo "Script needs root - execute bootstrap.sh or use sudo bash installation.sh"
echo "Script needs root - use sudo bash NS_Install.sh"
echo "Cannot continue.."
exit 5
fi

dialog --colors --msgbox " \Zr Developed by the xDrip team \Zn\n\n\n\
Some required packages will be installed now.\n\
It will take about 20 minutes.\n
This terminal needs to be kept open.\n\n\
If this is not a good time, you can press escape to cancel." 14 50
Test=0
#Test=1 ################ This line must be commented out before submitting a PR. ##########################

clear
dialog --colors --msgbox " \Zr Developed by the xDrip team \Zn\n\n\
Some required packages will be installed now. It will take about 15 minutes to complete. This terminal needs to be kept open. Press enter to proceed.\n\n\
If this is not a good time, you can press escape now to cancel." 13 50
if [ $? = 255 ]
then
clear
exit
fi
clear

if [ ! -s /var/SWAP ]
then
echo "Creating swap partition"
echo "Creating swap file"
dd if=/dev/zero of=/var/SWAP bs=1M count=2000
chmod 600 /var/SWAP
mkswap /var/SWAP
Expand All @@ -48,17 +51,29 @@ sudo apt-get -y install jq
echo -e "use Nightscout\ndb.createUser({user: \"username\", pwd: \"password\", roles:[\"readWrite\"]})\nquit()" | mongo
echo -e "use admin\ndb.createUser({ user: \"mongoadmin\" , pwd: \"mongoadmin\", roles: [\"userAdminAnyDatabase\", \"dbAdminAnyDatabase\", \"readWriteAnyDatabase\"]})\nquit()" | mongo

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

echo "Installing Node js"

sudo apt-get install -y nodejs npm
sudo apt -y autoremove

cd /srv

echo "Installing Nightscout"

if [ $Test -lt 1 ] # We are not testing.
then

sudo git clone https://github.com/jamorham/nightscout-vps.git
cd nightscout-vps
sudo git checkout vps-1
else # We are testing.

sudo git clone https://github.com/Navid200/cgm-remote-monitor.git
cd cgm-remote-monitor
sudo git checkout Navid_2022_11_16_Test
fi
sudo git pull

sudo npm install
Expand All @@ -68,6 +83,4 @@ for loop in 1 2 3 4 5 6 7 8 9
do
read -t 0.1 dummy
done

clear

Loading

0 comments on commit 85ce635

Please sign in to comment.