forked from ghosind/dvm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdvm.sh
executable file
·1035 lines (822 loc) · 19 KB
/
dvm.sh
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env bash
DVM_VERSION="v0.4.1"
compare_version() {
test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$2"
}
get_package_data() {
if [ "$(uname -m)" != 'x86_64' ]
then
echo '[ERR] only x64 binaries are supported.'
exit 1
fi
local min_version
local target_version
target_version="$1"
DVM_TARGET_OS=$(uname -s)
min_version="v0.36.0"
if compare_version "$target_version" "$min_version"
then
DVM_TARGET_TYPE="gz"
DVM_FILE_TYPE="gzip compressed data"
else
DVM_TARGET_TYPE="zip"
DVM_FILE_TYPE="Zip archive data"
fi
case "$DVM_TARGET_OS:$DVM_TARGET_TYPE" in
"Darwin:gz")
DVM_TARGET_NAME='deno_osx_x64.gz'
;;
"Linux:gz")
DVM_TARGET_NAME='deno_linux_x64.gz'
;;
"Darwin:zip")
DVM_TARGET_NAME='deno-x86_64-apple-darwin.zip'
;;
"Linux:zip")
DVM_TARGET_NAME='deno-x86_64-unknown-linux-gnu.zip'
;;
*)
echo "[ERR] unsupported operating system $DVM_TARGET_OS."
exit 1
;;
esac
}
# get_latest_version
# Calls GitHub api to getting deno latest release tag name.
get_latest_version() {
# the url of github api
local latest_url
# the response of requesting deno latest version
local response
# the latest release tag name
local tag_name
echo -e "\ntry to getting deno latest version ..."
latest_url="https://api.github.com/repos/denoland/deno/releases/latest"
if [ ! -x "$(command -v curl)" ]
then
echo "[ERR] curl is required."
exit 1
fi
if ! response=$(curl -s "$latest_url")
then
echo "[ERR] failed to getting deno latest version."
exit 1
fi
tag_name=$(echo "$response" | grep tag_name | cut -d '"' -f 4)
if [ -z "$tag_name" ]
then
echo "[ERR] failed to getting deno latest version."
exit 1
fi
DVM_TARGET_VERSION="$tag_name"
}
download_file() {
local cmd
local version
local url
local temp_file
version="$1"
if [ ! -d "$DVM_DIR/download/$version" ]
then
mkdir -p "$DVM_DIR/download/$version"
fi
if [ -z "$DVM_INSTALL_REGISTRY" ]
then
DVM_INSTALL_REGISTRY="https://github.com/denoland/deno/releases/download"
fi
url="$DVM_INSTALL_REGISTRY/$version/$DVM_TARGET_NAME"
temp_file="$DVM_DIR/download/$version/deno-downloading.$DVM_TARGET_TYPE"
if [ -x "$(command -v wget)" ]
then
cmd="wget $url -O $temp_file"
elif [ -x "$(command -v curl)" ]
then
cmd="curl -LJ $url -o $temp_file"
else
echo "[ERR] wget or curl is required."
exit 1
fi
if $cmd
then
local file_type
file_type=$(file "$temp_file")
if [[ $file_type == *"$DVM_FILE_TYPE"* ]]
then
mv "$temp_file" "$DVM_DIR/download/$version/deno.$DVM_TARGET_TYPE"
return
fi
fi
if [ -f "$temp_file" ]
then
rm "$temp_file"
fi
echo "[ERR] failed to download deno $version."
exit 1
}
extract_file() {
local target_dir
target_dir="$DVM_DIR/versions/$1"
if [ ! -d "$target_dir" ]
then
mkdir -p "$target_dir"
fi
case $DVM_TARGET_TYPE in
"zip")
if [ -x "$(command -v unzip)" ]
then
unzip "$DVM_DIR/download/$1/deno.zip" -d "$target_dir" > /dev/null
elif [ "$DVM_TARGET_OS" = "Linux" ] && [ -x "$(command -v gunzip)" ]
then
gunzip -c "$DVM_DIR/download/$1/deno.zip" > "$target_dir/deno"
chmod +x "$target_dir/deno"
else
echo "[ERR] unzip is required."
exit 1
fi
;;
"gz")
if [ -x "$(command -v gunzip)" ]
then
gunzip -c "$DVM_DIR/download/$1/deno.gz" > "$target_dir/deno"
chmod +x "$target_dir/deno"
else
echo "[ERR] gunzip is required."
exit 1
fi
;;
*)
;;
esac
}
# validate_remote_version
# Get remote version data by GitHub api (Get a release by tag name)
validate_remote_version() {
local version
# GitHub get release by tag name api url
local tag_url
version="$1"
tag_url="https://api.github.com/repos/denoland/deno/releases/tags/$version"
if [ ! -x "$(command -v curl)" ]
then
echo "[ERR] curl is required."
exit 1
fi
if ! response=$(curl -s "$tag_url")
then
echo "[ERR] failed to getting deno $version data."
exit 1
fi
tag_name=$(echo "$response" | grep tag_name | cut -d '"' -f 4)
if [ -z "$tag_name" ]
then
echo "[ERR] deno '$version' not found, use 'ls-remote' command to get available versions."
exit 1
fi
}
install_version() {
local version
version="$1"
if [ -z "$version" ]
then
get_latest_version
version="$DVM_TARGET_VERSION"
fi
if [ -f "$DVM_DIR/versions/$version/deno" ]
then
echo "Deno $version has been installed."
exit 0
fi
validate_remote_version "$version"
get_package_data "$version"
if [ ! -f "$DVM_DIR/download/$version/deno.$DVM_TARGET_TYPE" ]
then
echo "Downloading and installing deno $version..."
download_file "$version"
else
echo "Installing deno $version from cache..."
fi
extract_file "$version"
echo "Deno $version has installed."
}
uninstall_version() {
local current_bin_path
current_bin_path=$(file -h "$DVM_BIN/deno" | grep link | cut -d " " -f 5)
if [ "$current_bin_path" = "$DVM_DIR/versions/$DVM_TARGET_VERSION/deno" ]
then
rm "$DVM_BIN/deno"
fi
if [ -f "$DVM_DIR/versions/$DVM_TARGET_VERSION/deno" ]
then
rm -rf "$DVM_DIR/versions/$DVM_TARGET_VERSION"
echo "Uninstalled deno $DVM_TARGET_VERSION."
else
echo "Deno $DVM_TARGET_VERSION is not installed."
fi
}
list_aliases() {
local aliased_version
if [ ! -d "$DVM_DIR/aliases" ]
then
return
fi
for path in "$DVM_DIR/aliases"/*
do
if [ ! -f "$path" ]
then
continue;
fi
alias_name=${path##*/}
aliased_version=$(cat "$path")
if [ -z "$aliased_version" ] ||
[ ! -f "$DVM_DIR/versions/$aliased_version/deno" ]
then
echo "$alias_name -> N/A"
else
echo "$alias_name -> $aliased_version"
fi
done
}
list_local_versions() {
local version
get_current_version
if [ -d "$DVM_DIR/versions" ]
then
for dir in "$DVM_DIR/versions"/*
do
if [ ! -f "$dir/deno" ]
then
continue
fi
version=${dir##*/}
if [ "$version" = "$DVM_DENO_VERSION" ]
then
echo "-> $version"
else
echo " $version"
fi
done
fi
list_aliases
}
list_remote_versions() {
local releases_url
local all_versions
local page
local size
local num
local tmp_versions
local response
page=1
size=100
num="$size"
releases_url="https://api.github.com/repos/denoland/deno/releases?per_page=$size"
while [ "$num" -eq "$size" ]
do
if [ ! -x "$(command -v curl)" ]
then
echo "[ERR] curl is required."
exit 1
fi
if ! response=$(curl -s "$releases_url&page=$page")
then
echo "[ERR] failed to list remote versions."
exit 1
fi
tmp_versions=$(echo "$response" | grep tag_name | cut -d '"' -f 4)
num=$(echo "$tmp_versions" | wc -l)
page=$((page + 1))
if [ -n "$all_versions" ]
then
all_versions="$all_versions\n$tmp_versions"
else
all_versions="$tmp_versions"
fi
done
echo -e "$all_versions" | sed 'x;1!H;$!d;x'
}
check_dvm_dir() {
if [ -z "$DVM_DIR" ]
then
# set default dvm directory
DVM_DIR="$HOME/.dvm"
fi
if [ -z "$DVM_BIN" ]
then
DVM_BIN="$DVM_DIR/bin"
fi
}
clean_download_cache() {
for path in "$DVM_DIR/download"/*
do
if [ ! -d "$path" ]
then
continue
fi
[ -f "$path/deno-downloading.zip" ] && rm "$path/deno-downloading.zip"
[ -f "$path/deno-downloading.gz" ] && rm "$path/deno-downloading.gz"
[ -f "$path/deno.zip" ] && rm "$path/deno.zip"
[ -f "$path/deno.gz" ] && rm "$path/deno.gz"
rmdir "$path"
done
}
get_version_by_param() {
DVM_TARGET_VERSION=""
if [ "$#" = "0" ]
then
return
fi
if [ -f "$DVM_DIR/aliases/$1" ]
then
DVM_TARGET_VERSION=$(cat "$DVM_DIR/aliases/$1")
if [ ! -f "$DVM_DIR/versions/$DVM_TARGET_VERSION/deno" ]
then
DVM_TARGET_VERSION="$1"
fi
else
DVM_TARGET_VERSION="$1"
fi
}
get_version() {
local version
get_version_by_param "$@"
if [ -n "$DVM_TARGET_VERSION" ]
then
return
fi
if [ ! -f "./.dvmrc" ]
then
echo "No .dvmrc file found."
return
fi
DVM_TARGET_VERSION=$(cat ./.dvmrc)
}
# use_version
# Create a symbolic link file to make the specified deno version as active
# version, the symbolic link is linking to the specified deno executable file.
use_version() {
# deno executable file version
local deno_version
# target deno executable file path
local target_path
if [ ! -d "$DVM_BIN" ]
then
# create path if it is not exist
mkdir -p "$DVM_BIN"
fi
get_version "$1"
if [ -z "$DVM_TARGET_VERSION" ]
then
print_help
exit 1
fi
target_path="$DVM_DIR/versions/$DVM_TARGET_VERSION/deno"
if [ -f "$target_path" ]
then
# get target deno executable file version
deno_version=$("$target_path" --version | grep deno | cut -d " " -f 2)
if [ "$DVM_TARGET_VERSION" != "v$deno_version" ]
then
# print warnning message when deno version is different with parameter.
echo "[WARN] You may had upgraded this version, it is v$deno_version now."
fi
# create a new symbolic link, and link to specified deno executable file.
ln -sf "$target_path" "$DVM_BIN/deno"
echo "Using deno $DVM_TARGET_VERSION now."
else
echo "Deno $DVM_TARGET_VERSION is not installed, you can run 'dvm install $DVM_TARGET_VERSION' to install it."
exit 1
fi
}
get_current_version() {
local deno_path
local deno_dir
if [ ! -f "$DVM_BIN/deno" ]
then
return
fi
deno_path=$(readlink "$DVM_BIN/deno")
deno_dir=${deno_path%/deno}
DVM_DENO_VERSION=${deno_dir##*/}
}
check_alias_dir() {
if [ ! -d "$DVM_DIR/aliases" ]
then
mkdir -p "$DVM_DIR/aliases"
fi
}
set_alias() {
local alias_name
local version
check_alias_dir
alias_name="$1"
version="$2"
if [ ! -f "$DVM_DIR/versions/$version/deno" ]
then
echo "[ERR] deno $version is not installed."
exit 1
fi
echo "$version" > "$DVM_DIR/aliases/$alias_name"
echo "$alias_name -> $version"
}
rm_alias() {
local alias_name
local aliased_version
check_alias_dir
alias_name="$1"
if [ ! -f "$DVM_DIR/aliases/$alias_name" ]
then
echo "[ERR] alias $alias_name does not exist."
exit 1
fi
aliased_version=$(cat "$DVM_DIR/aliases/$alias_name")
rm "$DVM_DIR/aliases/$alias_name"
echo "Deleted alias $alias_name."
echo "Restore it with 'dvm alias $alias_name $aliased_version'."
}
run_with_version() {
if [ ! -f "$DVM_DIR/versions/$DVM_TARGET_VERSION/deno" ]
then
echo "[ERR] deno $DVM_TARGET_VERSION is not installed."
exit 1
fi
echo "Running with deno $DVM_TARGET_VERSION."
"$DVM_DIR/versions/$DVM_TARGET_VERSION/deno" "$@"
}
locate_version() {
local target_version
target_version="$DVM_TARGET_VERSION"
if [ "$1" = "current" ]
then
get_current_version
if [ -n "$DVM_DENO_VERSION" ]
then
target_version="$DVM_DENO_VERSION"
fi
fi
if [ -f "$DVM_DIR/versions/$target_version/deno" ]
then
echo "$DVM_DIR/versions/$target_version/deno"
else
echo "Deno $target_version is not installed."
fi
}
get_dvm_latest_version() {
local request_url
local field
local response
case "$DVM_SOURCE" in
gitee)
request_url="https://gitee.com/api/v5/repos/ghosind/dvm/releases/latest"
field="6"
;;
github|*)
request_url="https://api.github.com/repos/ghosind/dvm/releases/latest"
field="4"
;;
esac
if [ ! -x "$(command -v curl)" ]
then
echo "[ERR] curl is required."
exit 1
fi
if ! response=$(curl -s "$request_url")
then
echo "[ERR] failed to get the latest DVM version."
exit 1
fi
DVM_LATEST_VERSION=$(echo "$response" | grep tag_name | cut -d '"' -f $field)
}
update_dvm() {
if ! cd "$DVM_DIR" 2>/dev/null
then
echo "[ERR] failed to update dvm."
exit 1
fi
# reset changes if exists
git reset --hard HEAD
git fetch
git checkout "$DVM_LATEST_VERSION"
}
fix_invalid_versions() {
local version
if [ ! -d "$DVM_DIR/doctor_temp" ]
then
return
fi
for version_path in "$DVM_DIR/doctor_temp/"*
do
version=${version_path##*/}
if [ -d "$DVM_DIR/versions/$version" ]
then
rm -rf "$version_path"
else
mv "$version_path" "$DVM_DIR/versions/$version"
fi
done
rmdir "$DVM_DIR/doctor_temp"
}
print_doctor_message() {
local invalid_message
local corrupted_message
invalid_message="$1"
corrupted_message="$2"
if [ -z "$invalid_message" ] && [ -z "$corrupted_message" ]
then
echo "Everything is ok."
return
fi
if [ -n "$invalid_message" ]
then
echo "Invalid versions:"
echo -e "$invalid_message"
fi
if [ -n "$corrupted_message" ]
then
echo "Corrupted versions:"
echo -e "$corrupted_message"
fi
echo "You can run \"dvm doctor --fix\" to fix these errors."
}
scan_and_fix_versions() {
local mode
local raw_output
local invalid_message
local corrupted_message
local version
local deno_version
mode="$1"
for version_path in "$DVM_DIR/versions/"*
do
if [ ! -f "$version_path/deno" ]
then
continue
fi
version=${version_path##*/}
raw_output=$("$version_path/deno" --version 2>/dev/null)
if [ -z "$raw_output" ]
then
corrupted_message="$corrupted_message$version\n"
if [ "$mode" = "fix" ]
then
rm -rf "$version_path"
fi
else
deno_version=$(echo "$raw_output" | grep deno | cut -d " " -f 2)
if [ "$version" != "v$deno_version" ]
then
invalid_message="$invalid_message$version -> v$deno_version\n"
if [ "$mode" = "fix" ]
then
mkdir -p "$DVM_DIR/doctor_temp"
mv -f "$version_path" "$DVM_DIR/doctor_temp/v$deno_version"
fi
fi
fi
done
if [ "$mode" = "fix" ]
then
fix_invalid_versions
else
print_doctor_message "$invalid_message" "$corrupted_message"
fi
}
get_rc_file() {
case ${SHELL##*/} in
bash)
DVM_RC_FILE="$HOME/.bashrc"
;;
zsh)
DVM_RC_FILE="$HOME/.zshrc"
;;
*)
DVM_RC_FILE="$HOME/.profile"
;;
esac
}
confirm_with_prompt() {
local confirm
local prompt
if [ "$#" = 0 ]
then
return
fi
prompt="$1"
echo -n "$prompt (y/n) "
read -r confirm
case "$confirm" in
y|Y)
;;
n|N)
exit 0
;;
*)
exit 1
;;
esac
}
purge_dvm() {
local content
rm -rf "$DVM_DIR"
get_rc_file
content=$(sed "/Deno Version Manager/d;/DVM_DIR/d;/DVM_BIN/d" "$DVM_RC_FILE")
echo "$content" > "$DVM_RC_FILE"
echo "DVM has been removed from your computer."
}
print_help() {
printf "
Deno Version Manager
Usage:
dvm install Download and install the latest version or the version reading from .dvmrc file.
<version> Download and install the specified version from source.
--registry=<registry> Download and install deno with the specified registry.
dvm uninstall [name|version] Uninstall a specified version.
dvm use [name|version] Use the specified version that passed by argument or read from .dvmrc.
dvm run <name|version> [args] Run deno on the specified version with arguments.
dvm alias <name> <version> Set an alias name to specified version.
dvm unalias [name|version] Delete the specified alias name.
dvm current Display the current version of Deno.
dvm ls List all installed versions.
dvm ls-remote List all remote versions.
dvm which [current|name|version] Display the path of installed version.
dvm clean Remove all downloaded packages.
dvm doctor Scan installed versions and find invalid / corrupted versions.
--fix Scan and fix all invalid / corrupted versions.
dvm upgrade Upgrade dvm itself.
dvm purge Remove dvm from your computer.
dvm help Show this message.
Examples:
dvm install v1.0.0
dvm uninstall v0.42.0
dvm use v1.0.0
dvm alias default v1.0.0
dvm run v1.0.0 app.ts
"
}
dvm() {
local version
check_dvm_dir
if [ "$#" = "0" ]
then
print_help
exit 0
fi
case $1 in
install)
# install the specified version
shift
version=""
while [ "$#" -gt "0" ]
do
case "$1" in
"--registry="*)
DVM_INSTALL_REGISTRY=${1#--registry=}
;;
*)
version="$1"
;;
esac
shift
done
if [ -z "$version" ]
then
if [ -f "./.dvmrc" ]
then
version=$(cat ./.dvmrc)
else
echo "No .dvmrc file found"
fi
fi
install_version "$version"
;;
uninstall)
# uninstall the specified version
shift
get_version "$@"
if [ "$DVM_TARGET_VERSION" = "" ]
then
print_help
exit 1
fi
uninstall_version "$DVM_TARGET_VERSION"
;;
list | ls)
# list all local versions
list_local_versions
;;
list-remote | ls-remote)
# list all remote versions
list_remote_versions
;;
current)
# get the current version
get_current_version
if [ -n "$DVM_DENO_VERSION" ]
then
echo "$DVM_DENO_VERSION"
else
echo "none"
fi
;;
use)
# change current version to specified version
shift
use_version "$@"
;;
clean)
# remove all download packages.
clean_download_cache
;;
alias)
shift
if [ "$#" -lt "2" ]
then
print_help
exit 1
fi
set_alias "$@"
;;
unalias)
shift
if [ "$#" -lt "1" ]
then
print_help
exit 1
fi
rm_alias "$1"
;;
run)
shift
get_version "$@"
if [ "$DVM_TARGET_VERSION" = "" ]
then
print_help
exit 1
fi
if [ "$#" != "0" ]
then
shift
fi
run_with_version "$@"
;;
which)
shift
get_version "$@"
if [ -z "$DVM_TARGET_VERSION" ]
then
print_help
exit 1
fi
locate_version "$@"
;;
upgrade)
get_dvm_latest_version
if [ "$DVM_LATEST_VERSION" = "$DVM_VERSION" ]
then
echo "dvm is update to date."
exit 0
fi
update_dvm
;;
doctor)
local mode
shift
while [ "$#" -gt "0" ]
do
case "$1" in
"--fix")
mode="fix"
;;
*)
echo "[ERR] unsupprot option \"$1\"."
exit 1
;;
esac
shift
done
if [ "$mode" == "fix" ]
then