-
Notifications
You must be signed in to change notification settings - Fork 0
/
vnmik.registry.tools
executable file
·63 lines (59 loc) · 1.73 KB
/
vnmik.registry.tools
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!bash
registry_backup()
{
stat_msg "backing up current TeX system configuration..."
local prefix=$PREFIX/vnmik.log/bk.`date +%y.%m.%d`
if [ -d $prefix ]; then
stat_warn "backup directory does exist: $prefix"
query 'y' "press y to backup again. Old data will be lost"
if [ $? -gt 0 ]; then
return 0
fi
fi
mkdir -p $prefix > /dev/null
if [ $? -ge 1 ]; then
stat_warn "failed to create directory $prefix"
return 1
fi
cd $prefix
echo -ne '' > tmp
reg export 'HKCU\Software\Classes\.dvi' dvi.reg >> tmp 2>>nul
reg export 'HKCU\Software\Classes\.ps' ps.reg >> tmp 2>>nul
reg export 'HKCU\Software\MiKTeX.org\MiKTeX\2.7' mik1.reg >> tmp 2>>nul
reg export 'HKLM\Software\MiKTeX.org\MiKTeX\2.7' mik2.reg >> tmp 2>>nul
[ -f "$USERHOME/gsview32.ini" ] && (cp "$USERHOME/gsview32.ini" gsview32.ini -v >> tmp)
stat_log_file tmp
}
# registry add a key
registry_add()
{
local skip_subkey_check=0
if [ "x$1" == "x--skip-subkey-check" ]; then
skip_subkey_check=1
shift
fi
local key="$3"
local value="$2"
local kind="$1"
stat_log "registry update: $kind, value=$value, key=$key, path=$path"
if [ $skip_subkey_check == 1 ]; then
stat_log "skip subkey check. may cause some errors in regtool's set action"
else
stat_log "getting list of subkeys..."
local sub_keys=""
local tmp_st="$key"
while [ "$tmp_st" != "/" ]; do
tmp_st="`dirname \"$tmp_st\"`"
sub_keys="$tmp_st $sub_keys"
done
for sub_key in $sub_keys; do
stat_log "creating subkey: $sub_key"
regtool add $sub_key > /dev/null 2>&1
done
stat_log "last return status: $?"
fi
stat_log "going to execute: regtool set \"$kind\" \"$key\" \"$value\""
regtool set $kind "$key" "$value"
stat_log "return status: $?"
}
stat_log "library loaded: vnmik.registry.tools"