Monday, December 25, 2017

Updates and backups and logs oh my!

I run Linux on my laptop. So when my daughter said she needed a laptop, I pieced one together, dropped Linux on it and handed it over. She took it home... and let me make this clear... she took it home. How to do upgrades? She isn't a technophobe, just lazy. So I thought, what if I wrote a script, that configures her laptop to handle updates, backups, then emails me when it's done.

That sounds ambitious. So lets find the best way to do all of this together.

so for backups I use

tar cvpzf backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys /


this puts a backup tar in the / folder (we have to start there too)

so we can say

#!/bin/bash
# let's talk to the lUser and let them know it's gonna take awhile
echo HI, I just need to do some configuration stuff, Please wait until I'm done
echo This will take a bit probably


:wq out of that and then change the permissions
chmod u+x updatescript

that allows it to be runnable.

I'm adding an option to shutdown when I'm done. something like

shutdown=true

if you use shutdown = true, it will try to run the command shutdown. That's not what we want, we want a bool shutdown that is initialized to true. Conversely, (and we may use this later) delete a variable with unset so unset shutdown, deletes the variable shutdown. We don't want that so we are just going to shut down by default, but ask if she wants us to leave it on.

echo would you like to shutdown on completion?

Windows NEEDS a reboot usually, Linux not so much. Thats just so that she has the option to come back to what she was doing the night before, or see that it's shut down and know it's done. so now we need to read in her answer. so I'm going to let her type in her answer and read it in and check it. so

read shutdown #important to note that c based programmers will pull their hair out with lack of ;

now you can
echo $shutdown

at this point you can read in anything to shutdown. If you type Floppychoppydingdang that's what that will save in the variable

So the NEXT thing that needs to be done, is to parse the input and decide if she wants it shutdown or not... or if one of her kids is banging on the keyboard again.
That sounds like another day.

No comments:

Post a Comment