igyigy
Posts: 12
Joined: Mon Jun 17, 2019 2:01 pm

Lance a script automatically that logs my raspberry pi3 to my server

Mon Jun 17, 2019 2:14 pm

Hello to everyone,
I am brand new on programming in general and especially with linux , so i may ask some questions that may appear obvious to some of you.

I want my raspberry pi to send a request and downloads files from my server automatiqually at booting.
So my question is :

How to lance an automatic log to my server : in which directory in which file and what should i write ?
In the other hand how to configure my server to accept my raspberry's request ?

How to download specific files from the server ?

I really need your help !!

THank you all

User avatar
topguy
Posts: 5899
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Lance a script automatically that logs my raspberry pi3 to my server

Mon Jun 17, 2019 2:49 pm

What kind of server is it ? web-server (http), FTP server, File server ( Windows share etc )

igyigy
Posts: 12
Joined: Mon Jun 17, 2019 2:01 pm

Re: Lance a script automatically that logs my raspberry pi3 to my server

Mon Jun 17, 2019 2:56 pm

I am still confused about the server type
What I need is a local server where I can store some files and download them through tcp/ip
From this specifications can you tell which server do I need for my application ?

Ernst
Posts: 1246
Joined: Sat Feb 04, 2017 9:39 am
Location: Germany

Re: Lance a script automatically that logs my raspberry pi3 to my server

Mon Jun 17, 2019 3:19 pm

igyigy wrote:
Mon Jun 17, 2019 2:14 pm

I am brand new on programming in general and especially with linux
Start here: https://www.raspberrypi.org/magpi/
The road to insanity is paved with static ip addresses

Andyroo

Re: Lance a script automatically that logs my raspberry pi3 to my server

Mon Jun 17, 2019 5:29 pm

topguy wrote:
Mon Jun 17, 2019 2:49 pm
What kind of server is it ? web-server (http), FTP server, File server ( Windows share etc )
Just set up a simple Windows share / SAMBA share and use rsync to copy files over. You can set the program up to only copy new files or missing files - depends on what you want to do.

igyigy
Posts: 12
Joined: Mon Jun 17, 2019 2:01 pm

Re: Lance a script automatically that logs my raspberry pi3 to my server

Mon Jun 17, 2019 6:38 pm

@Andyroo i would like to strore files in the size of a linux os image

Andyroo

Re: Lance a script automatically that logs my raspberry pi3 to my server

Mon Jun 17, 2019 8:22 pm

rsync can handle gigabytes but you will have to think about how you are going to store that amount of data on the Pi and how long its going to take. Pi boards are not known for their network / disk speeds (but I'm biased as I come from fibre / SAN disks :lol: )

I would use an USB connected HD rather than a large SD card

If time is an issue, you can break the program in the middle of a file transfer and get it to continue again appending to the file.

It will also verify files after getting them and can keep two folders in sync so if you delete one from the Pc it can be automatically deleted from the Pi. It is not smart enough to handle renames - it deletes the old file name on the Pi and copies the renamed file as a new one.

The official page is https://rsync.samba.org

igyigy
Posts: 12
Joined: Mon Jun 17, 2019 2:01 pm

Re: Lance a script automatically that logs my raspberry pi3 to my server

Mon Jun 17, 2019 8:29 pm

@Andyroo thanks a lot
i wonder if you can tell more about the script that will allows me to do this task ?
And how to configure my server to accept the rasp requests ?

Thanks a lot

User avatar
rpdom
Posts: 15417
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Lance a script automatically that logs my raspberry pi3 to my server

Mon Jun 17, 2019 8:38 pm

What is the server? PC, Pi, Mac?

What OS is it running?

My file server is a Pi with NFS and Samba shares. I use NFS for Linux and Samba for Windows.

There's no need for rsync for these, just mount the shares as networked drives and use the normal copy commands or file manager.

igyigy
Posts: 12
Joined: Mon Jun 17, 2019 2:01 pm

Re: Lance a script automatically that logs my raspberry pi3 to my server

Mon Jun 17, 2019 8:42 pm

My pc is debain 18.04
Raspberry pi 3 B+ with raspbian os
for the server i will do as you suggested rsync

tpyo kingg
Posts: 627
Joined: Mon Apr 09, 2018 5:26 pm
Location: N. Finland

Re: Lance a script automatically that logs my raspberry pi3 to my server

Tue Jun 18, 2019 5:13 am

If you are using rsync, you can get there with the following steps

1. Enable OpenSSH on the Debian PC. Ensure you can log in with SSH from the Raspberry Pi.
2. Set up key-based authentication from the Raspberry Pi to the Debian PC. Ensure you can log in using just the keys.
3. Turn off password-based authentication for SSH on the Debian PC.
4. Tell rsync to use the keys using its -e option from the Raspberry Pi to the Debian PC.

Each of those steps may need some exploration and reading online. Be sure to check the reference manuals.

Code: Select all

man ssh
man ssh-keygen
man ssh-copy-id
man sshd_config
man rsync
They are not tutorials but it is very, very useful to at least gradually become familar with them and be able to skim through them look things up. They are good referene material in that way.

igyigy
Posts: 12
Joined: Mon Jun 17, 2019 2:01 pm

Re: Lance a script automatically that logs my raspberry pi3 to my server

Tue Jun 18, 2019 9:43 am

Thank you all

I still have a question
i want you to imagine a software that enables an OS installation automatically, knowing that the os image is stored somewhere in my raspberry pi.
I want you to suggest an archiitecture for doing this so i can have an idea
I know there are experts among us :p

User avatar
rpdom
Posts: 15417
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Lance a script automatically that logs my raspberry pi3 to my server

Tue Jun 18, 2019 9:50 am

igyigy wrote:
Tue Jun 18, 2019 9:43 am
i want you to imagine a software that enables an OS installation automatically, knowing that the os image is stored somewhere in my raspberry pi.
Assuming the system that the OS is to be installed on has no OS to start with, that is tricky. It would require something to boot from to start the process, like a USB stick. In that case you might as well put the whole OS and installer on the USB stick.

If it is a Pi 3B+, you can boot it over the wired network without having to put an SD card or USB device in it. There are details on how to do that in the official documentation.

You can do the same thing with many PCs, but you may have to go into the BIOS (or equivalent) setup to enable it.

Is that what you wanted?

igyigy
Posts: 12
Joined: Mon Jun 17, 2019 2:01 pm

Re: Lance a script automatically that logs my raspberry pi3 to my server

Tue Jun 18, 2019 10:07 am

Actually I suppose that I already have an os runing and another is image stored somewhere
And want to know how can I enable the os image installation which a program like a script for exemple ?

User avatar
rpdom
Posts: 15417
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Lance a script automatically that logs my raspberry pi3 to my server

Tue Jun 18, 2019 10:30 am

(This has diverged from the original topic and should really be in its own thread.)
igyigy wrote:
Tue Jun 18, 2019 10:07 am
Actually I suppose that I already have an os runing and another is image stored somewhere
And want to know how can I enable the os image installation which a program like a script for exemple?
Those specifications are still lacking in any detail. We cannot read your mind (though transference is against forum rules :-( )

What sort of OS? Linux, Windows, MacOS or other?
What hardware is it to be installed on?
What OS will be on there originally?

It is difficult to install another OS over the top of the one that is currently running on most systems. Mostly because the old OS will be constantly accessing files on the storage media (SD card/Hard disk, etc) and will get a little upset if those files are suddenly pulled out from underneath it. Also it may keep writing to files that are no longer there and corrupt the new OS data.

Installers tend to run small versions of an OS in RAM, so the main storage medium is not being used and can be safely overwritten.

igyigy
Posts: 12
Joined: Mon Jun 17, 2019 2:01 pm

Re: Lance a script automatically that logs my raspberry pi3 to my server

Tue Jun 18, 2019 10:44 am

OK you are right i may not specify some aspects.
I admit i have a raspbian os runing in my raspberry pi, on another hand i may download for exaple the latest version of raspbian, after the download is complete i would like to install the new version and crush the oldest.

I hope i was clear this time

User avatar
rpdom
Posts: 15417
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Lance a script automatically that logs my raspberry pi3 to my server

Tue Jun 18, 2019 10:53 am

Ok, for the Pi it is usually recommended that you turn it off, take out the SD card and install the latest Raspbian image on it.

If you are just upgrading from an older release of Raspbian Stretch to the latest release, you don't need to reinstall, you can upgrade with apt-get upgrade (or apt-get dist-upgrade) and maybe a reboot.

Upgrading to Buster (when that is released) should be the same - it'll be nice if the RPF can let us know of any software they have added that might need to be manually installed when upgrading from Stretch Lite/Desktop/Full to the equivalent Buster versions. Also upgrade notes - don't need to be detailed, just a summary of which files need to be changed and commands run to complete the upgrade.

igyigy
Posts: 12
Joined: Mon Jun 17, 2019 2:01 pm

Re: Lance a script automatically that logs my raspberry pi3 to my server

Tue Jun 18, 2019 11:00 am

I know that i can simply use upgrade command, but this is not what i want to experience, i want to write a script able to call the os image downloaded, launch it to install and erase the old one or store ot as a backup

User avatar
rpdom
Posts: 15417
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Lance a script automatically that logs my raspberry pi3 to my server

Tue Jun 18, 2019 11:21 am

I have already explained why that can be difficult/almost impossible. The original OS is using files on the SD card (or USB device or whatever you are using for storage). You can't just overwrite all that information and expect the system not to crash.

It may be possible, but it would be a lot of work. One method would be for the script to reconfigure the system to reboot using a RAM disk instead of the SD card, then install the OS and reboot back into the upgraded system.

Don't forget that all files will be deleted and overwritten, so any user configuration, documents etc will vanish.

igyigy
Posts: 12
Joined: Mon Jun 17, 2019 2:01 pm

Re: Lance a script automatically that logs my raspberry pi3 to my server

Tue Jun 18, 2019 11:31 am

Is it memory space that causes problem? if yes,
I can use an SD card that can support as much data

If it's not the memory issue tell me please why the system is going to crush ?

Thanks

User avatar
topguy
Posts: 5899
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Lance a script automatically that logs my raspberry pi3 to my server

Tue Jun 18, 2019 11:44 am

Its could also be a memory issue since the Pi also only have 1GB memory.

But the main problem is that you cant reformat a SD card while you are running an OS from the same SD card. What do you think would happen if you did "format c:" on a Windows PC while it was running.

igyigy
Posts: 12
Joined: Mon Jun 17, 2019 2:01 pm

Re: Lance a script automatically that logs my raspberry pi3 to my server

Tue Jun 18, 2019 12:00 pm

What if i partition my sd card so i can have my os runing in a partition and other data on the a separated partition

User avatar
rpdom
Posts: 15417
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Lance a script automatically that logs my raspberry pi3 to my server

Tue Jun 18, 2019 12:03 pm

Imagine trying to change major parts of the engine on a car while you are driving...
igyigy wrote:
Tue Jun 18, 2019 12:00 pm
What if i partition my sd card so i can have my os runing in a partition and other data on the a separated partition
You still have to change the partitions on the card. It won't work.

Ernst
Posts: 1246
Joined: Sat Feb 04, 2017 9:39 am
Location: Germany

Re: Lance a script automatically that logs my raspberry pi3 to my server

Tue Jun 18, 2019 12:09 pm

igyigy wrote:
Tue Jun 18, 2019 11:00 am
I know that i can simply use upgrade command, but this is not what i want to experience, i want to write a script able to call the os image downloaded, launch it to install and erase the old one or store ot as a backup
Can you please explain exactly how you visualize this process, how do you expect the process to work, what are the requirements and expectations ?
The road to insanity is paved with static ip addresses

igyigy
Posts: 12
Joined: Mon Jun 17, 2019 2:01 pm

Re: Lance a script automatically that logs my raspberry pi3 to my server

Tue Jun 18, 2019 12:50 pm

I expect to have a bootloader dependant partition
and the meta data in another partition
so my bootloader partition is untouchable, i want only the meta data to get replaced by the new ones

Return to “Raspbian”