]>
Commit | Line | Data |
---|---|---|
b153f197 SP |
1 | --- vmware-distrib/bin/vmware 2005-03-23 05:54:18.000000000 -0600 |
2 | +++ vmware-distrib.new/bin/vmware 2005-04-13 09:35:12.000000000 -0500 | |
3 | @@ -8,162 +8,7 @@ | |
4 | # the VMware software is installed. --hpreg | |
5 | # | |
6 | ||
da9b5371 | 7 | -# BEGINNING_OF_DB_DOT_SH |
8 | -#!/bin/sh | |
9 | - | |
10 | -# | |
11 | -# Manage an installer database | |
12 | -# | |
13 | - | |
14 | -# Add an answer to a database in memory | |
15 | -db_answer_add() { | |
16 | - local dbvar="$1" # IN/OUT | |
17 | - local id="$2" # IN | |
18 | - local value="$3" # IN | |
19 | - local answers | |
20 | - local i | |
21 | - | |
22 | - eval "$dbvar"'_answer_'"$id"'="$value"' | |
23 | - | |
24 | - eval 'answers="$'"$dbvar"'_answers"' | |
25 | - # There is no double quote around $answers on purpose | |
26 | - for i in $answers; do | |
27 | - if [ "$i" = "$id" ]; then | |
28 | - return | |
29 | - fi | |
30 | - done | |
31 | - answers="$answers"' '"$id" | |
32 | - eval "$dbvar"'_answers="$answers"' | |
33 | -} | |
34 | - | |
35 | -# Remove an answer from a database in memory | |
36 | -db_answer_remove() { | |
37 | - local dbvar="$1" # IN/OUT | |
38 | - local id="$2" # IN | |
39 | - local new_answers | |
40 | - local answers | |
41 | - local i | |
42 | - | |
43 | - eval 'unset '"$dbvar"'_answer_'"$id" | |
44 | - | |
45 | - new_answers='' | |
46 | - eval 'answers="$'"$dbvar"'_answers"' | |
47 | - # There is no double quote around $answers on purpose | |
48 | - for i in $answers; do | |
49 | - if [ "$i" != "$id" ]; then | |
50 | - new_answers="$new_answers"' '"$i" | |
51 | - fi | |
52 | - done | |
53 | - eval "$dbvar"'_answers="$new_answers"' | |
54 | -} | |
55 | - | |
56 | -# Load all answers from a database on stdin to memory (<dbvar>_answer_* | |
57 | -# variables) | |
58 | -db_load_from_stdin() { | |
59 | - local dbvar="$1" # OUT | |
60 | - | |
61 | - eval "$dbvar"'_answers=""' | |
62 | - | |
63 | - # read doesn't support -r on FreeBSD 3.x. For this reason, the following line | |
64 | - # is patched to remove the -r in case of FreeBSD tools build. So don't make | |
65 | - # changes to it. -- Jeremy Bar | |
66 | - while read -r action p1 p2; do | |
67 | - if [ "$action" = 'answer' ]; then | |
68 | - db_answer_add "$dbvar" "$p1" "$p2" | |
69 | - elif [ "$action" = 'remove_answer' ]; then | |
70 | - db_answer_remove "$dbvar" "$p1" | |
71 | - fi | |
72 | - done | |
73 | -} | |
74 | - | |
75 | -# Load all answers from a database on disk to memory (<dbvar>_answer_* | |
76 | -# variables) | |
77 | -db_load() { | |
78 | - local dbvar="$1" # OUT | |
79 | - local dbfile="$2" # IN | |
80 | - | |
81 | - db_load_from_stdin "$dbvar" < "$dbfile" | |
82 | -} | |
83 | - | |
84 | -# Iterate through all answers in a database in memory, calling <func> with | |
85 | -# id/value pairs and the remaining arguments to this function | |
86 | -db_iterate() { | |
87 | - local dbvar="$1" # IN | |
88 | - local func="$2" # IN | |
89 | - shift 2 | |
90 | - local answers | |
91 | - local i | |
92 | - local value | |
93 | - | |
94 | - eval 'answers="$'"$dbvar"'_answers"' | |
95 | - # There is no double quote around $answers on purpose | |
96 | - for i in $answers; do | |
97 | - eval 'value="$'"$dbvar"'_answer_'"$i"'"' | |
98 | - "$func" "$i" "$value" "$@" | |
99 | - done | |
100 | -} | |
101 | - | |
102 | -# If it exists in memory, remove an answer from a database (disk and memory) | |
103 | -db_remove_answer() { | |
104 | - local dbvar="$1" # IN/OUT | |
105 | - local dbfile="$2" # IN | |
106 | - local id="$3" # IN | |
107 | - local answers | |
108 | - local i | |
109 | - | |
110 | - eval 'answers="$'"$dbvar"'_answers"' | |
111 | - # There is no double quote around $answers on purpose | |
112 | - for i in $answers; do | |
113 | - if [ "$i" = "$id" ]; then | |
114 | - echo 'remove_answer '"$id" >> "$dbfile" | |
115 | - db_answer_remove "$dbvar" "$id" | |
116 | - return | |
117 | - fi | |
118 | - done | |
119 | -} | |
120 | - | |
121 | -# Add an answer to a database (disk and memory) | |
122 | -db_add_answer() { | |
123 | - local dbvar="$1" # IN/OUT | |
124 | - local dbfile="$2" # IN | |
125 | - local id="$3" # IN | |
126 | - local value="$4" # IN | |
127 | - | |
128 | - db_remove_answer "$dbvar" "$dbfile" "$id" | |
129 | - echo 'answer '"$id"' '"$value" >> "$dbfile" | |
130 | - db_answer_add "$dbvar" "$id" "$value" | |
131 | -} | |
132 | - | |
133 | -# Add a file to a database on disk | |
134 | -# 'file' is the file to put in the database (it may not exist on the disk) | |
135 | -# 'tsfile' is the file to get the timestamp from, '' if no timestamp | |
136 | -db_add_file() { | |
137 | - local dbfile="$1" # IN | |
138 | - local file="$2" # IN | |
139 | - local tsfile="$3" # IN | |
140 | - local date | |
141 | - | |
142 | - if [ "$tsfile" = '' ]; then | |
143 | - echo 'file '"$file" >> "$dbfile" | |
144 | - else | |
145 | - date=`date -r "$tsfile" '+%s' 2> /dev/null` | |
146 | - if [ "$date" != '' ]; then | |
147 | - date=' '"$date" | |
148 | - fi | |
149 | - echo 'file '"$file$date" >> "$dbfile" | |
150 | - fi | |
151 | -} | |
152 | - | |
153 | -# Add a directory to a database on disk | |
154 | -db_add_dir() { | |
155 | - local dbfile="$1" # IN | |
156 | - local dir="$2" # IN | |
157 | - | |
158 | - echo 'directory '"$dir" >> "$dbfile" | |
159 | -} | |
b153f197 SP |
160 | -# END_OF_DB_DOT_SH |
161 | - | |
da9b5371 | 162 | -db_load 'vm_db' '/etc/vmware/locations' |
163 | +. /etc/vmware/locations | |
164 | ||
b153f197 SP |
165 | if [ "vmware" = "vmware-console" ]; then |
166 | vmware_config_name="vmware-config-console" |