TDengine 850 字节
Newer Older
wafwerar's avatar
wafwerar 已提交
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
#!/usr/bin/env bash


function showAlertMessage(){
osascript <<EOF
	set buttonStr to "${3}"
	set oldDelimiters to AppleScript's text item delimiters
	set AppleScript's text item delimiters to ","
	set buttonList to every text item of buttonStr
	set AppleScript's text item delimiters to oldDelimiters
	get buttonList
	set btns to buttonList
	display dialog "${1}" with title "${2}" buttons btns with icon ${4}
	get result 
EOF
}

taosd_status=`Launchctl list | grep taosd | head -n 1 | awk '{print $1}'`
if [ "$taosd_status"x = "-"x ]; then
    launchctl start taosd
    showAlertMessage "Taosd is running!" "TDengine" "ok" "note"
else
    choose_result=`showAlertMessage "Taosd is running!\nDo you want to close it?" "TDengine" "yes,cancel" "stop"`
    if [ "$choose_result"x = "button returned:yes"x ]; then
        launchctl stop taosd
    fi
fi