bash:学习

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
#!/usr/bin/env bash
#
# ${SF_COPYRIGHT}
#
# author: chunyang liu
#
# this script used to install skyform monitor production
#
#
 
# check it the production directory. make sure package are OK.
#
DIRS=(bin conf lib scripts)
for d in ${DIRS[*]};do
    if [ ! -e $d ];then
        echo "ERROR: missing product module $d."
        echo "INFO: you may need to download well-formated package and make sure it's OK."
        exit -1;
    fi
done
 
# global env
export DRIVER_ROOT=/opt/vmware-driver
 
DRIVER_JAR=vmware-driver.jar
NVC_TAR=noVNC.tar.gz
RETCODE=0
 
setup_menu()
{
    # setup menu
    MENU_KEYS=(I U Q)
    MENU_DISPLAY=('[I]nstall and Config SkyForm Vmware Driver'
        '[U]ninstall SkyForm Vmware Driver'
        '[Q]uit installation.')
    MENU_ACTION=(install_driver uninstall_driver quit)
}
 
install_driver()
{
    # check the old installation.
    if [ -d "$DRIVER_ROOT" ];then
        echo "WARN: found an old mointor server installation in $DRIVER_ROOT"
        echo "If you continue installation, the old one will be erased."
        printf "Continue installation (Y/N)?: "
        read YN
        case "$YN" in
            "Y") ;;
    "y") ;;
            *)
                echo "You have chosen 'No'. Quit the installation."
                exit 0;
        esac
         
        rm -rf "$DRIVER_ROOT"
    fi
 
    echo "It will need severial minutes, please waiting"
 
    mkdir -p "$DRIVER_ROOT"
     
    cp -rf ./conf $DRIVER_ROOT/.
    cp -rf ./lib $DRIVER_ROOT/.
    cp -rf ./bin $DRIVER_ROOT/.
    cp -rf ./scripts $DRIVER_ROOT/.
    cp -rf ./$DRIVER_JAR $DRIVER_ROOT/.
    mkdir -p $DRIVER_ROOT/logs
    chmod 777 $DRIVER_ROOT/logs -R
    chmod -R 755 $DRIVER_ROOT/bin/*
    chmod -R 755 $DRIVER_ROOT/scripts/*
    chmod -R 755 $DRIVER_ROOT/$DRIVER_JAR
     
    rpm -e jdk-1.7.0_02-fcs.x86_64 2>/dev/null
    rpm -qa | grep java | xargs rpm -e --nodeps 2>/dev/null
    rpm -qa | grep jre | xargs rpm -e --nodeps 2>/dev/null
    rpm -qa | grep jdk | xargs rpm -e --nodeps 2>/dev/null
    cd $DRIVER_ROOT/lib
    tar zxvf jdk-7u2-linux-x86_64.tar.gz
    cd jdk-7u2-linux-x86_64
    sh scripts/install.sh 2>/dev/snull
 
    vncinfo=`cat /etc/rc.local|grep "vnc"`
     
    if [ x"$vncinfo" = x ]
    then
        mkdir -p /root/tokens
        cd /opt
        tar -zxvf $DRIVER_ROOT/lib/$NVC_TAR
        echo "cd /opt/noVNC/utils" >> /etc/rc.local
        echo "nohup ./websockify --web /opt/noVNC/ --target-config=/root/tokens 6080 >> /opt/noVNC/novnc.log 2>&1 &" >> /etc/rc.local
        cd /opt/noVNC/utils
        nohup ./websockify --web /opt/noVNC/ --target-config=/root/tokens 6080 >> /opt/noVNC/novnc.log 2>&1 &
    fi
     
    echo "Install vmware-driver Succeed!\n"
    setup_menu;
    menu;
}
 
uninstall_driver()
{
    if [ -d "$DRIVER_ROOT" ] ; then
        rm -rf "$DRIVER_ROOT"
    fi
     
    rpm -e jdk-1.7.0_02-fcs.x86_64 2>/dev/null
    rpm -qa | grep java | xargs rpm -e --nodeps 2>/dev/null
    rpm -qa | grep jre | xargs rpm -e --nodeps 2>/dev/null
    rpm -qa | grep jdk | xargs rpm -e --nodeps 2>/dev/null
     
    /bin/sh /opt/vmware-driver/bin/vmware-driver-stop.sh -r all
 
    echo "Uninstall vmware-driver Succeed!\n"
    setup_menu;
    menu;
}
 
menu()
{
    local MENU_LEN=${#MENU_KEYS[@]}
    local ACTION_LEN=${#MENU_ACTION[@]}
    if [ $MENU_LEN != $ACTION_LEN ];then
        echo "Assert error: the menu item doesnot match the action item"
        exit 1;
    fi
 
    # header
    [ ! -z "${MENU_HEADER}" ] && printf "${MENU_HEADER}"
 
    # menu body
    for ((i=0; i < $MENU_LEN; i++ )); do
        printf "\t${MENU_KEYS[$i]}) ${MENU_DISPLAY[$i]}\n"
    done
     
    printf "\t> "
    read CHOICE
    [ -z "$CHOICE" ] && echo "Aarning: empty choice. Quit." && exit 1;
     
    HIT=0
    for ((i=0; i < $MENU_LEN; i++)); do
        CHOICE=`echo $CHOICE | tr [A-Z] [a-z]`
        KEY=`echo ${MENU_KEYS[$i]} | tr [A-Z] [a-z]`
        [ "${CHOICE}" == "${KEY}" ] && HIT=1 && eval ${MENU_ACTION[$i]}
    done
    [ ${HIT} == 0 ] && echo "Invalid choice '$CHOICE'. Quit."; exit 1;
    exit $RETCODE
}
 
quit()
{
    exit $RETCODE
}
 
##############################
# main
setup_menu;
menu;

  

posted on   lydstory  阅读(89)  评论(0编辑  收藏  举报

编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
历史上的今天:
2020-01-12 常见的矢量格式图(SVG,EPS,wmf,emf)
2020-01-12 公司名称
2018-01-12 linux bluez
2018-01-12 c++ explicit

导航

< 2025年3月 >
23 24 25 26 27 28 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 1 2 3 4 5

统计

点击右上角即可分享
微信分享提示