userspace:opsi-info
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| userspace:opsi-info [2013/09/03 18:41] – islam | userspace:opsi-info [2021/08/23 10:37] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | opsi-info | + | **opsi-info** |
| opsi-info.sh | opsi-info.sh | ||
| shell script to change version information of available opsi packages | shell script to change version information of available opsi packages | ||
| + | |||
| + | **Features: | ||
| + | |||
| + | - Display Version and package-version of any opsi product | ||
| + | |||
| + | - Edit Version and package-version of any opsi product | ||
| + | |||
| + | - Change Product version if defined in setup script (setup.ins) | ||
| + | |||
| + | updates this File String in setup.ins: | ||
| + | < | ||
| + | replacing the version number can be useful if you use the version as parameter in your setup script, for example | ||
| + | < | ||
| + | |||
| + | This means, updating Firefox would just require you to place the new setup exe file inside " | ||
| + | then setting the the new version with opsi-info.sh | ||
| + | |||
| + | - optionally set " | ||
| + | |||
| Download Link here: http:// | Download Link here: http:// | ||
| - | <code Bash> | + | ############################ |
| + | opsi-info : view / edit opsi package information | ||
| + | |||
| + | usage: | ||
| + | |||
| + | opsi-info [arguments] | ||
| + | |||
| + | arguments: | ||
| + | |||
| + | -h : | ||
| + | |||
| + | -prod [product-id] : | ||
| + | |||
| + | -ver [decimal] : | ||
| + | |||
| + | -pver [integer] : | ||
| + | |||
| + | |||
| + | example: <code Bash> | ||
| + | |||
| + | sets new version " | ||
| + | |||
| + | |||
| + | ############################ | ||
| + | |||
| + | **opsi-info.sh** | ||
| + | |||
| + | <code Bash> | ||
| #!/bin/bash | #!/bin/bash | ||
| Line 24: | Line 70: | ||
| # 2013-09-02 view, | # 2013-09-02 view, | ||
| # 2013-09-03 view, | # 2013-09-03 view, | ||
| + | # 2013-12-10 added option to update clients with product already installed, set correct file rights for edited files | ||
| + | |||
| + | # target: - prompt for software setup on all clients with status " | ||
| + | |||
| + | # General-Info to find installed product on client: | ||
| + | |||
| + | # installed info: | ||
| + | # in / | ||
| + | # | ||
| + | # function: | ||
| + | # Find string " | ||
| + | # | ||
| + | # Set for setup | ||
| + | # change from " | ||
| + | # to: " | ||
| + | # | ||
| #target: - read/edit opsi package information | #target: - read/edit opsi package information | ||
| # - list all package-ids | # - list all package-ids | ||
| Line 41: | Line 103: | ||
| ###################### | ###################### | ||
| # global variables | # global variables | ||
| - | ver=" | + | ver=" |
| #set loop delimiter as " | #set loop delimiter as " | ||
| IFS=$' | IFS=$' | ||
| Line 193: | Line 255: | ||
| depot_tmp2=" | depot_tmp2=" | ||
| if [ -f $depot_tmp2 ]; then rm -f $depot_tmp2; | if [ -f $depot_tmp2 ]; then rm -f $depot_tmp2; | ||
| + | } | ||
| + | |||
| + | #find clients with installed product and set for setup | ||
| + | f_UpdateClients() { | ||
| + | # Find string " | ||
| + | |||
| + | # first find clients, display names and prompt | ||
| + | # use: grep -l " | ||
| + | |||
| + | echo | ||
| + | echo " | ||
| + | echo | ||
| + | |||
| + | # Set number of clients found with product already installed | ||
| + | updclient=0 | ||
| + | #Path of clients Folder | ||
| + | clientspath="/ | ||
| + | #backup path for clients | ||
| + | client_bak_dir="/ | ||
| + | #create backup folder if not exist | ||
| + | if [ ! -d " | ||
| + | |||
| + | # find all clients with product already installed and not set to setup | ||
| + | for c in $(grep -l " | ||
| + | # print client names with product already installed, trim .ini extension | ||
| + | # print client name only - trim .ini extension, trim dir path | ||
| + | #echo ${c%.ini} | ||
| + | echo " | ||
| + | # Add number of clients and check later if results >0 | ||
| + | updclient=$((updclient + 1)) | ||
| + | done | ||
| + | |||
| + | #If results found, begin interaction | ||
| + | if [ " | ||
| + | # message if search results is 0 | ||
| + | echo | ||
| + | echo "[ ${product} ] is not installed on any client." | ||
| + | echo | ||
| + | else | ||
| + | echo | ||
| + | echo "[ ${updclient} ] clients found." | ||
| + | echo | ||
| + | # Now ask if setup action should be set. | ||
| + | |||
| + | ### | ||
| + | read -n1 -p " Set SETUP action for [ ${product} ] on listed clients ? : [ y=Yes | n=No ]: [Default: y ] " | ||
| + | case " | ||
| + | # use last path accepted | ||
| + | "" | ||
| + | # yes I want to set product for setup on clients | ||
| + | #echo | ||
| + | echo " | ||
| + | echo | ||
| + | for c in $(grep -l " | ||
| + | # print client names with product already installed, trim .ini extension | ||
| + | #echo ${c%.ini} | ||
| + | # Add number of clients and check later if results >0 | ||
| + | # | ||
| + | |||
| + | # backup client files first | ||
| + | #cp -f " | ||
| + | # backup original file to backup dir, trimming source file name only adding date.bak as suffix | ||
| + | cp -f " | ||
| + | # begin replacing string into tmp file | ||
| + | cat " | ||
| + | # replace tmp file with original file | ||
| + | mv -f " | ||
| + | # set file rights | ||
| + | chown opsiconfd: | ||
| + | chmod 660 " | ||
| + | |||
| + | #verify edit | ||
| + | if grep -q " | ||
| + | then | ||
| + | # code if found | ||
| + | echo "OK: SETUP action set for: $(echo ${c} | xargs -n1 basename)" | ||
| + | else | ||
| + | # code if not found | ||
| + | error "SETUP action NOT set for: $(echo ${c} | xargs -n1 basename)" | ||
| + | fi | ||
| + | done | ||
| + | ;; | ||
| + | # skip file, any other entry | ||
| + | *) | ||
| + | # Any other answer is now | ||
| + | # No changes | ||
| + | echo "No clients have been modified." | ||
| + | echo | ||
| + | ;; | ||
| + | esac | ||
| + | |||
| + | fi | ||
| + | |||
| } | } | ||
| Line 219: | Line 374: | ||
| cat " | cat " | ||
| mv -f " | mv -f " | ||
| + | # set file rights | ||
| + | chown opsiconfd: | ||
| + | chmod 660 " | ||
| #verify edit | #verify edit | ||
| Line 283: | Line 441: | ||
| # verify change, #later | # verify change, #later | ||
| # cat " | # cat " | ||
| + | # set file rights | ||
| + | chown opsiconfd: | ||
| + | chmod 660 " | ||
| + | |||
| #### change file version in setup script | #### change file version in setup script | ||
| f_Install | f_Install | ||
| + | ### update installed clients | ||
| + | f_UpdateClients | ||
| ;; | ;; | ||
| 3) # change package version / sed ====> first match for version: only / first occurence | 3) # change package version / sed ====> first match for version: only / first occurence | ||
| Line 291: | Line 455: | ||
| #cat " | #cat " | ||
| mv -f " | mv -f " | ||
| + | # set file rights | ||
| + | chown opsiconfd: | ||
| + | chmod 660 " | ||
| ;; | ;; | ||
| 4) #change prod. version first, then pkg version | 4) #change prod. version first, then pkg version | ||
| Line 296: | Line 463: | ||
| cat " | cat " | ||
| #mv -f " | #mv -f " | ||
| + | # set file rights | ||
| + | chown opsiconfd: | ||
| + | chmod 660 " | ||
| #### change file version in setup script | #### change file version in setup script | ||
| f_Install | f_Install | ||
| + | ### update installed clients | ||
| + | f_UpdateClients | ||
| ;; | ;; | ||
| esac | esac | ||
| Line 307: | Line 479: | ||
| #restore backed up file | #restore backed up file | ||
| mv -f $depot_bak_file $depot | mv -f $depot_bak_file $depot | ||
| + | # set file rights | ||
| + | chown opsiconfd: | ||
| + | chmod 660 $depot | ||
| fi | fi | ||
| } | } | ||
| Line 398: | Line 573: | ||
| # replace version info and retain original file structure | # replace version info and retain original file structure | ||
| sed ' | sed ' | ||
| + | # set file rights | ||
| + | chown opsiconfd: | ||
| + | chmod 660 $depot | ||
| f_Product | f_Product | ||
| ;; | ;; | ||
| Line 404: | Line 582: | ||
| cp -f $depot $depot_bak_file | cp -f $depot $depot_bak_file | ||
| sed ' | sed ' | ||
| + | # set file rights | ||
| + | chown opsiconfd: | ||
| + | chmod 660 $depot | ||
| # change further files | # change further files | ||
| f_Product | f_Product | ||
| Line 413: | Line 594: | ||
| # replace version info and retain original file structure | # replace version info and retain original file structure | ||
| sed ' | sed ' | ||
| + | # set file rights | ||
| + | chown opsiconfd: | ||
| + | chmod 660 $depot | ||
| # change further files | # change further files | ||
| f_Product | f_Product | ||
| Line 438: | Line 622: | ||
| #read -p "" | #read -p "" | ||
| #exit | #exit | ||
| - | |||
| </ | </ | ||
userspace/opsi-info.1378226475.txt.gz · Last modified: (external edit)
