In order to solve that problem i had to think about a solution that will constantly remind me of my pending tasks and forces me to complete them.
Have you ever been wondering if there is a way to join someones shell, terminal, command line (or what ever you would name it) remotely ?
Here is the solution:
Taskwarrior is a command-line todo list manager
I use it at work and at home, but that made some problems to me. It has become very confusing which task belongs to which group of my life.
Do i have to call Mr. Miller for private thing or for business ?
For solving this problem i wrote a tiny bash script and i want to share it with you
At work i need to use an application that can store and restore images of an computer. I am using Clonezilla to do so. Clonezilla is an distribution of Debian(sid) which does all those jobs. The advantage is that it is very customizable. Because i am storing all the images at the same space and using the same network setup i has become contra productive to setup it again and again for every single image . Thank god Clonezilla can run a prerunscript which does this for me. If you want to do the same get the lastest version of clonezilla as .zip file and extract it. Changes need to be done in the /syslinux/syslinux.cfgfile which defines the menu is shown when booting clonezilla.
# MENU HIDE
MENU LABEL Restore
# MENU PASSWD
append initrd=/live/initrd.img boot=live config noswap nolocales edd=on nomodeset ocs_prerun="mount -t cifs -o user=admin,domain=domain.net 172.28.64.141:/Images /home/partimag" ocs_live_run="/opt/drbl/sbin/ocs-sr -u restoredisk ask_user sda" ocs_live_extra_param="" ocs_live_keymap="" ocs_live_batch="no" ocs_lang="en_US.UTF-8" vga=788 toram=filesystem.squashfs nosplash
Restore a stored image
# MENU DEFAULT
# MENU HIDE
MENU LABEL Store
# MENU PASSWD
append initrd=/live/initrd.img boot=live config noswap nolocales edd=on nomodeset noprompt ocs_prerun="mount -t cifs -o user=admin,domain=domain.net 172.28.64.141:/Images /home/partimag" ocs_live_run="/opt/drbl/sbin/ocs-sr -u -q2 -z1p -i 2048 -p poweroff savedisk ask_user sda" ocs_live_extra_param="" ocs_live_keymap="" ocs_live_batch="no" ocs_lang="en_US.UTF-8" vga=788 toram=filesystem.squashfs nosplash
Store an image
Here we have two menu entries, i replaced those i did not need. I will explain the meaning of the syntax now for you:
- label – Defines the option just for the config an can be set with any value
- MENU DEFAULT – This defines which option should be booted if the countdown is over (define only once in config, use # for the rest)
- MENU HIDE - Hides the menu.
- MENU LABEL – The Label that is shown in menu.
- MENU PASSWD – You could ask for an password when choosing the option but it is not needed to me.
- “kernel /live/vmlinuzappend initrd=/live/initrd.img boot=live config noswap nolocales edd=on nomodeset” – Starts clonezilla as it is.
- ocs_prerun=”mount -t cifs -o user=administrator,domain=domain.net 172.28.64.141:/Images /home/partimag” ocs_live_run=”/opt/drbl/sbin/ocs-sr -u restoredisk ask_user sda” ocs_live_extra_param=”" ocs_live_keymap=”/usr/share/keymaps/i386/qwertz/de-latin1.kmap.gz” ocs_live_batch=”no” ocs_lang=”en_US.UTF-8″ vga=788 toram=filesystem.squashfs nosplash- Here it becomes very tricky. Do not worry i will explain it for you:
- ocs_prerun= – Commands in this value will run before clonezilla starts.
- mount -t cifs -o- mounts a samba share with parameters:
- user =admin – Login as “admin”
- domain=domain.net – name of the domain (if you don’t know leave it blank. Home spaces do not use domains )
- 172.28.64.141:/Images – Place where the Images are stored or should be placed
- /home/partimag – Clonezilla mounts the images here which is the reason it does not ask for any other place to search for the images.
- ocs_live_run=”/opt/drbl/sbin/ocs-sr -u restoredisk ask_user sda” - ocs_live_run is defined two times in my config. This one runs the restore function of Clonezilla.
- ocs_live_run=”/opt/drbl/sbin/ocs-sr -u -q2 -z1p -i 2048 -p poweroff savedisk ask_user sda- This is the second entry which runs the store function:
- -u - Asks the user for the image name (could be set in config too).
- restoredisk or savedisk - Which mode to run ? store, restore, partition or hard-drive ?
- ask_user - This would be the name of the image but “-u” requests it from user.
- sda – Which hard-drive should be written or red.
- -q2 – Use “partclone”. I am preferring this .
- -z1p – Use gzip-Kompression (with multicore)
- -i 2048 – Splitzise in megabyte (Split every 2GB a new file for the backup.)
- -p poweroff - power off after successfully running the script.
- toram=filesystem.squashfs – Extracts all files to a ramdisk. Therefore you can remove the stick when clonezilla is booted.
After we modified our script we can flash it to an flashdrive (e.g using UnetBootIn or something like that) and test it.
If you have any problems with this how-to feel free to ask me for help and more information.
Diesen Artikel gibt es auch in Deutsch!
This is a short How-to for a while loop which echoes “LOOP!” :
do echo "LOOP!"
- while: starts the loop (in the brackets there is the constraint). Because an undefined variable is always “true” the loop will restart endless.
- do: Contains what the loop should do. For this example it echoes “Loop!”.
- sleep X – The script wait X second before continuing. (3 seconds here).
- done – Ends the loop
You can save the script and run it in shell using “bash SCRIPTNAME” or use “chmod a+x” to make it runnable and start it by clicking at it.