need help with updates for my program

Post Reply
sadams54
Posts: 14
Joined: Monday 09th July 2018 3:43am

need help with updates for my program

Post by sadams54 » Thursday 23rd August 2018 11:55pm

I am attempting to write an automatic update feature into my software. what it does is, goes to a specified location (web) and checks the version list of software with it's detected version to determine if update is available. If a newer version exists my program will download the new version. The blockade I hit is moving the downloaded program into the application directory which is usually "filesystem/bin". Then I need to exit the program and start the new version for the user.
The reason I am not doing this with "dnf" is my software is not in repository.

My thought is to do this in the program with a check for update option in the menu. I am open to other easy ideas or a way to move the downloaded file into possibly protected areas without having to modify the user system. I would rather not change the sudo config to allow the move command to operate without password.

I am open to other methods if they are not too tough. I do have a web host for the files if that matters.

User avatar
cogier
Site Admin
Posts: 193
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: need help with updates for my program

Post by cogier » Friday 24th August 2018 9:46am

Have a look at a program I wrote some time ago that will do what you requested. On the Gambas Farm you will find 'AutoUpdater'. Make an executable of it and put it on your Desktop. Don't run it yet as nothing will happen. Edit the Desktop file so you can add an -s switch to the command e.g. '/home/me/gambas/AutoUpdater/AutoUpdater.gambas' -s. This will make the program start in 'Settings' mode.

You just need to point to where the .tar (not .tar.gz) file of your updated Gambas program is stored and also where the '.gambas' file to update is.

Get your code to pull down the file, as a .tar file of your program, from the web into a folder. The program stores the date of the file so will know it it has changed.

Get your program to call AutoUpdater (without the -s switch), making sure your program is not doing something important as AutoUpdater will 'Kill' your program if an update is required.

Read 'Help' in the program. I use this program at work on a daily basis and it works very well. It is very fast, it even stores your old programs and creates a log. Any issues let me know.

sadams54
Posts: 14
Joined: Monday 09th July 2018 3:43am

Re: need help with updates for my program

Post by sadams54 » Saturday 25th August 2018 8:27pm

an interesting possibility however I am trying to make this self contained in the program and not require additional software to be installed.
I have also been exploring creating a repo for my stuff but I do not have root access to the web host I would use. so createrepo will not help me.

User avatar
cogier
Site Admin
Posts: 193
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: need help with updates for my program

Post by cogier » Sunday 26th August 2018 7:54am

Your program can't closed itself, update and restart. You will need another program to do this for you or you will have to do the job yourself. AutoUpdater does not require any user intervention to do the update.

If you use Dropbox or similar you won't need a 'repo'.

sadams54
Posts: 14
Joined: Monday 09th July 2018 3:43am

Re: need help with updates for my program

Post by sadams54 » Tuesday 28th August 2018 9:36pm

I can have my program run a shell command with a delay to restart itself. I also have a web host to put my stuff onto but just need to move the downloaded program into the application directory which is usually bin. I can't shell or do anything to put my new update into the protected folder without root privledge for a few seconds.

User avatar
cogier
Site Admin
Posts: 193
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: need help with updates for my program

Post by cogier » Wednesday 29th August 2018 4:22pm

Why does you program need to be in /bin? If it needs to go there you could use my 'Sudo' program on the Farm but this will require the user to enter the password.

Can you post the program here so we can see how it might be done?

sadams54
Posts: 14
Joined: Monday 09th July 2018 3:43am

Re: need help with updates for my program

Post by sadams54 » Wednesday 29th August 2018 9:21pm

Thank you, I looked over your program and tried to implement the shell sudo command unsuccessfully. I ran your program and even though I am putting in the correct password for root, (checked using stop to see the variables) it still says invalid password. this is happening in your program at the shell command.

You are using a very simple solution that I like but still can't get either program to take it. Using fedora 28 if that helps you at all. Also used terminal to put in the command with the echo and same result.

sadams54
Posts: 14
Joined: Monday 09th July 2018 3:43am

Re: need help with updates for my program

Post by sadams54 » Thursday 30th August 2018 12:39am

I just figured it out I think. the command used in your sudo program was missing the semicolon. should be echo <password> | sudo -S; <command>

the subtle difference is the semicolon after the -S seems to make it work.

User avatar
cogier
Site Admin
Posts: 193
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: need help with updates for my program

Post by cogier » Thursday 30th August 2018 4:22pm

..your sudo program was missing the semicolon.
I thought 'That's interesting' so I installed Fedora 28 and Gambas. I installed 'Sudo' and had all sorts of problems as my name was not in the 'sudoers' file and I was going to be reported! :(

Anyway once I had sorted that I had no problem as all, I did not need to add a semicolon so I am not sure why you have had to.

sadams54
Posts: 14
Joined: Monday 09th July 2018 3:43am

Re: need help with updates for my program

Post by sadams54 » Thursday 30th August 2018 6:43pm

for my purposes I want to remove the user as much as possible and have the program do the work. Just let user provide root password for update each time. This makes it tougher on me because I try to make sure that the user does not need to install all kinds of other things to function or make any changes to system. I just do not believe in that. especially if you have a group of users, they should not have to conform to me, I should conform to them. Your program gave me the insight needed so thank you. As for the semicolon it might have to do with the sodoers file since I leave it untouched. Not sure but not worried long as it does the trick. I might end up figuring out what the semicolon is about and optionally put it in when needed.

Post Reply