#!/bin/bash


Install(){
    
    #检测用户组不存在则添加用户组
    if ! getent group gbasedbt > /dev/null; then
        groupadd gbasedbt
    fi

    #检测用户不存在则添加用户
    if ! id -u gbasedbt > /dev/null 2>&1; then
        useradd -s /sbin/nologin -M -g gbasedbt gbasedbt
    fi

    #检测目录/www/server/gbasedbt不存在则创建目录
    if [ ! -d /www/server/gbasedbt ]; then
        mkdir -p /www/server/gbasedbt
    fi

    #修改目录权限
    chown -R gbasedbt:gbasedbt /www/server/gbasedbt


    arch=$(uname -m)

    tarName ="GBase8sV8.8_x86_64.tar"
    #下载并解压文件
    if [ ! -f /www/server/gbasedbt/gbasedbt.tar.gz ]; then
        wget -O /www/server/gbasedbt/gbasedbt.tar http://download.bt.cn//linux/GBase/$tarName
    fi

    cd /www/server/gbasedbt
    tar -xvf gbasedbt.tar

    #tmp目录临时增加到5G
    mount -o remount,size=5G /tmp
    #安装GBase8s
    sh ids_install
}

Uninstall(){
    
}

actionType=$1
version=$2

if [ "${actionType}" == 'install' ] || [ "${actionType}" == "update" ];then

elif [ "$actionType" == 'uninstall' ];then
	Uninstall del
fi