This shows you the differences between two versions of the page.
| — | userspace:vorlage [2022/02/14 14:17] (current) Thomas_H created | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ===== update... -VORLAGE- ===== | ||
| + | By  // | ||
| + | This is the template to create the self-updating scripts for your packages. If you change anything to something better or more efficient, so please let me know. Thank you. | ||
| + | |||
| + | < | ||
| + | #!/bin/bash | ||
| + | # | ||
| + | ############################################################################## | ||
| + | # first we declare some variables. A good programmer is a lazy programmer :) | ||
| + | ############################################################################## | ||
| + | opsiproduct_path="/ | ||
| + | product=" | ||
| + | setupname=" | ||
| + | geturl=" | ||
| + | urladd="/ | ||
| + | # Attention! following grepvar-string is a regular expression!! Leave the [^"]* at the end!! | ||
| + | grepvar="" | ||
| + | searchstr="" | ||
| + | alt_ver=$(date +" | ||
| + | startpos=0 | ||
| + | ############################################################################## | ||
| + | # | ||
| + | # ATTENTION! FOR TESTING FIRST ALL REAL COMMANDS ARE COMMENTED OUT BY # --- !! WHEN CHANGING TO PRODUCTION YOU'LL HAVE TO REMOVE THE # --- THEN! | ||
| + | # | ||
| + | # first, let's remove the last valid exe-file | ||
| + | # --- rm $opsiproduct_path/ | ||
| + | |||
| + | # get the new setup-file from website and rename it to a standard file name (so no need to change the setup.ins :P ) | ||
| + | |||
| + | if [ " | ||
| + | setupprg=$setupname | ||
| + | else | ||
| + | # here we try to find the full name of the new setup-file. For example we know start and ending of the file, but not the rest. | ||
| + | # Example: Setup-file-name is always " | ||
| + | # " | ||
| + | # | ||
| + | setupprg=$( wget --no-check-certificate $geturl -q -O- | grep -o $grepvar ) | ||
| + | fi | ||
| + | |||
| + | echo setupprg=$setupprg | ||
| + | # --- wget --no-check-certificate " | ||
| + | |||
| + | # Do we need to unzip the file first? If so, watch the right name of setup.exe is written in setup.ins | ||
| + | # --- unzip -o $opsiproduct_path/ | ||
| + | # --- rm  $opsiproduct_path/ | ||
| + | |||
| + | # let's change the directory to the package | ||
| + | cd $opsiproduct_path/ | ||
| + | # remove the *.opsi-files | ||
| + | # --- rm *.opsi | ||
| + | # --- rm *.zsync | ||
| + | # --- rm *.md5 | ||
| + | |||
| + | # to find out, which version it is, we do a little bit of awk | ||
| + | if [ $startpos != 0 ]; then | ||
| + | pos=$(echo $setupprg | grep -b -o $searchstr | awk 'BEGIN {FS=":" | ||
| + | # well done, we found it. | ||
| + | version=$(echo $setupprg | cut -c$startpos-$pos) | ||
| + | else | ||
| + | version=$alt_ver | ||
| + | fi | ||
| + | echo Version=$version | ||
| + | # now let's change the / | ||
| + | # --- sed " | ||
| + | # --- mv $opsiproduct_path/ | ||
| + | |||
| + | # make new package, but quiet | ||
| + | # --- opsi-makepackage -q | ||
| + | # --- opsi-package-manager -i *.opsi | ||
| + | </ | ||