1

I am working on an IoT project using a Raspberry That connects to a couple of sensors gathers data, saves into a local database then at the end of the day sends all the data to a remote server. unfortunately, we cannot make many connections due to a data cap.

This is my first job as a programmer and I am not sure I have used best practices on everything, and before sending these devices, I would like to hear some feedback from people with experience.

1) to be able to update the pi, I have set up scripts that check git-lab api once a day and download the repo when there is a new version. is this common, is it acceptable?

2) the Raspberry pi keeps track of the version of the file by writing than into a text-file, should I use a database instead?

3) I disabled SSH, for security and data cap. however, I have a script that checks GitHub for a file and executes commands if there is any on that file. is this acceptable?

Please advise me, if those approaches are common and acceptable, if you see any flaw and what would you recommend instead.

Thank you,

  • 1
    1) yes, 2) no, 3) yes – Jaromanda X Jan 29 at 4:48
  • 1. Can check once a month, if your version update means utility software update. 2. Very confusing. 3. Very confusing. GitHub will be annoyed. – tlfong01 Jan 29 at 5:14
  • Welcome, David -- but please read "What types of questions should I avoid asking?" and take the tour if you have not yet. Note that most of this is really off-topic here; there is no such category as "linux programming concept" at this level of abstraction, and what you are asking about are really general design questions in which the brand of hardware and operating system are not particularly relevant (presuming the latter is a normative, multi-tasking, general purpose one, which it is). – goldilocks Jan 29 at 11:53
  • Questions which might be on topic WRT the OS, if you have no experience with it, might be, "Can I do _____?" regarding some specific technology (language, database, etc) you want to use. However, those are probably better asked on our larger parent site, Stack Overflow or Unix & Linux. – goldilocks Jan 29 at 11:56
3

1) to be able to update the pi, I have set up scripts that check git-lab API once a day and download the repo when there is a new version. is this common, is it acceptable?

Yes, also you can follow the procedure below. It's easy to create a scheduled script thanks to the "cron".

1. Create a file for the script:

sudo touch /home/update-script

2. Open the script file:

sudo nano /home/update-script  

3. Add these lines to the file:

#!/bin/bash -e

# First updating the repository list
/usr/bin/sudo apt-get update

# Then upgrade packages etc
/usr/bin/sudo apt-get -y upgrade

# Finally rpi-update
/usr/bin/sudo rpi-update

# Trigger a reboot
/usr/bin/sudo shutdown -r

The -e after the #!/bin/bash will stop this script if any errors occur.

4. Add execute permission to this script file (not much force):

sudo chmod +x /home/update-script

5. Schedule the script, fire the command below and select nano if it asks you:

crontab -e

6. Add this line:

0 3 * * * /home/update-script 2>&1 >/home/update-script.output

It will run this script at 3 am every day and make an output file for logging. Moreover, if you want to change the scheduled time as you want, the structure is like this: Source

# * * * * *  command to execute
# ┬ ┬ ┬ ┬ ┬
# │ │ │ │ │
# │ │ │ │ │
# │ │ │ │ └───── day of the week (0 - 7) (0 to 6 are Sunday to Saturday, or use names; 7 is Sunday, the same as 0)
# │ │ │ └────────── month (1 - 12)
# │ │ └─────────────── day of the month (1 - 31)
# │ └──────────────────── hour (0 - 23)
# └───────────────────────── min (0 - 59)  

It all makes you able to update the raspberry pi/raspbian automatically.


2) the Raspberry pi keeps track of the version of the file by writing than into a text-file, should I use a database instead?

If it's related to the question number one, No. However, if you write things in a simple file, it's easy to use but it's also risky. The databases always are much reliable but a bit hard to configure and make a connection for your programs, script, etc anyway.


3) I disabled SSH, for security and data cap. however, I have a script that checks GitHub for a file and executes commands if there is any on that file. is this acceptable?

Short answer, almost everything is acceptable if you are working on a Linux box. You execute commands on a local machine. It doesn't matter if the SSH enabled or disabled.

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.