Browse Source

add installer

apkipa 2 months ago
parent
commit
90dc07dba0

+ 2 - 0
.gitignore

@@ -0,0 +1,2 @@
+release
+tmp

+ 8 - 0
.idea/.gitignore

@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml

+ 9 - 0
.idea/minio-into-ck.iml

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="WEB_MODULE" version="4">
+  <component name="Go" enabled="true" />
+  <component name="NewModuleRootManager">
+    <content url="file://$MODULE_DIR$" />
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+  </component>
+</module>

+ 8 - 0
.idea/modules.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectModuleManager">
+    <modules>
+      <module fileurl="file://$PROJECT_DIR$/.idea/minio-into-ck.iml" filepath="$PROJECT_DIR$/.idea/minio-into-ck.iml" />
+    </modules>
+  </component>
+</project>

+ 6 - 0
.idea/vcs.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="VcsDirectoryMappings">
+    <mapping directory="$PROJECT_DIR$" vcs="Git" />
+  </component>
+</project>

+ 26 - 0
minio-into-ck-installer/install.sh

@@ -0,0 +1,26 @@
+#! /bin/bash
+if [ $UID -ne 0 ]; then
+    echo "请用root用户运行当前脚本 (su root)" && exit 1
+fi
+if [ -r /opt/minio-into-ck/minio-into-ck  ];then
+      echo "/opt/minio-into-ck/minio-into-ck文件夹已存在,请重命名旧版本文件后再尝试"
+      exit
+fi
+root_dir=/opt/minio-into-ck
+
+if [ ! -d "$root_dir" ]; then
+        mkdir -p $root_dir
+fi
+
+tar zxf ./minio-into-ck.tar.gz -C $root_dir
+cp -f minio-into-ck.service /usr/lib/systemd/system/
+if [ ! -r /opt/minio-into-ck/minio-into-ck  ];then
+      echo "安装失败!"
+      exit
+ else
+      echo "安装成功!"
+  fi
+chmod +x /opt/minio-into-ck/minio-into-ck/*.sh
+chmod +x /opt/minio-into-ck/minio-into-ck/minio-into-ck
+
+systemctl daemon-reload

+ 15 - 0
minio-into-ck-installer/minio-into-ck.service

@@ -0,0 +1,15 @@
+[Unit]
+Description=minio-into-ck
+After=minio-into-ck.service
+  
+[Service]
+Type=forking
+User=root
+Group=root
+ExecStart=/opt/minio-into-ck/minio-into-ck/run.sh
+ExecReload=/opt/minio-into-ck/minio-into-ck/restart.sh
+ExecStop=/opt/minio-into-ck/minio-into-ck/stop.sh
+PrivateTmp=true
+  
+[Install]
+WantedBy=multi-user.target

+ 24 - 0
minio-into-ck-installer/uninstall.sh

@@ -0,0 +1,24 @@
+#!/bin/bash
+if [ $UID -ne 0 ]; then
+    echo "请用root用户运行当前脚本 (su root)" && exit 1
+fi
+root_dir=/opt/minio-into-ck
+
+if [ ! -d "$root_dir" ]; then
+        mkdir -p $root_dir
+fi
+
+# Don't delete `/`
+if [[ $root_dir == "/" ]]; then
+    echo "root_dir is /, exit"
+    exit 1
+fi
+
+systemctl stop minio-into-ck
+
+rm -rf $root_dir
+rm -f /usr/lib/systemd/system/minio-into-ck.service
+
+echo "卸载成功!"
+
+systemctl daemon-reload

+ 13 - 0
minio-into-ck-installer/安装说明.txt

@@ -0,0 +1,13 @@
+version: v1.0.0
+install.sh脚本用于自动将minio-into-ck时序数据库安装在/opt/minio-into-ck/minio-into-ck下
+如存在旧版本文件需要重新命名
+(以下操作均需通过root用户执行)
+1. chmod +x *.sh给脚本可执行权限
+2. 执行./install.sh安装minio-into-ck
+3. 进入/opt/minio-into-ck/minio-into-ck路径下,完成授权操作
+4. 至此minio-into-ck可作为minio-into-ck服务运行
+启动:systemctl start minio-into-ck
+停止:systemctl stop minio-into-ck
+重启: systemctl restart minio-into-ck
+查看状态:systemctl status minio-into-ck
+开机自启:systemctl enable minio-into-ck

BIN
minio-into-ck/minio-into-ck


+ 42 - 0
minio-into-ck/restart.sh

@@ -0,0 +1,42 @@
+#!/usr/bin/env bash
+
+cat << 'LOGO'
+###############################################################
+   
+                           重启脚本
+
+                运行此脚本时可附加参数(不加参数则视为全部重启)
+                        -1 storage
+                        -2 insert
+                        -3 query
+
+###############################################################                                             
+LOGO
+base_dir=$(
+    cd "$(dirname "$0")"
+    pwd
+)
+cd $base_dir
+# extra function
+## func of log
+function log_warn() {
+    local date=$(date "+%Y-%m-%d-%H:%M:%S")
+    local para=$1
+    echo "[WARN] $date $1"
+
+}
+
+function log_info() {
+    local date=$(date "+%Y-%m-%d-%H:%M:%S")
+    local para=$1
+    echo "[INFO] $date $1"
+}
+
+function log_err() {
+    local date=$(date "+%Y-%m-%d-%H:%M:%S")
+    local para=$1
+    echo -e "[ERROR] $date $1"
+}
+
+./stop.sh no_logo "$@" && ./run.sh no_logo
+log_info "服务重启结束"

+ 82 - 0
minio-into-ck/run.sh

@@ -0,0 +1,82 @@
+#!/usr/bin/env bash
+set +u
+set -e
+# set -x
+base_dir=$(
+    cd "$(dirname "$0")"
+    pwd
+)
+cd $base_dir
+echo $base_dir
+# ./auto_del_log.sh
+function log_warn() {
+    local date=$(date "+%Y-%m-%d-%H:%M:%S")
+    local para=$1
+    echo "[WARN] $date $1" | tee -a "./log/run_log"
+
+}
+
+function log_info() {
+    local date=$(date "+%Y-%m-%d-%H:%M:%S")
+    local para=$1
+    echo "[INFO] $date $1" | tee -a "./log/run_log"
+}
+
+function log_err() {
+    local date=$(date "+%Y-%m-%d-%H:%M:%S")
+    local para=$1
+    echo "[ERROR] $date $1" | tee -a "./log/run_log"
+}
+
+ulimit -n 100000
+if [[ $1 != "no_logo" ]]; then
+    cat << 'LOGO'
+###############################################################
+
+                        配置文件:
+                        ./config/
+
+###############################################################
+LOGO
+else
+    shift 1
+fi
+
+# parameter set
+log_path="./log/minio-into-ck/"
+
+# extra function
+if [[ ! -d "$base_dir/log" ]]; then
+    echo "log文件夹不存在,创建log文件夹" && mkdir "./log"
+fi
+
+# preparation check
+if [[ ! -d "$base_dir/lib" ]]; then
+    log_err "缺少lib文件夹,请查证后重新运行此脚本" && exit 1
+fi
+
+if [[ ! -f "$base_dir/minio-into-ck" ]]; then
+    log_err "文件夹中缺少minio-into-ck(主程序),无法运行" && exit 1
+fi
+
+if [[ ! -x "$base_dir/minio-into-ck" ]]; then
+    log_err "minio-into-ck无可执行权限,无法运行。请使用chmod" && exit 1
+fi
+
+if [[ ! -f "$base_dir/license/license_key.json" ]]; then
+    log_warn "您可能未开始、或未完成授权过程.现在生成key,请之后完成授权过程再启动此脚本"
+    # exit 1
+fi
+
+
+###################################################################################################
+if ps -auxc | grep "minio-into-ck" | grep -v grep > /dev/null; then
+    log_info "minio-into-ck已在运行"
+else
+    if [[ ! -d $log_path ]]; then
+        mkdir "$log_path"
+    fi
+    log_file="minio-into-ck_$(date "+%Y-%m-%d-%H:%M:%S").log"
+    ./minio-into-ck server --config-file=$base_dir/config/config.xml &> "${log_path}${log_file}" &
+    ./status.sh
+fi

+ 25 - 0
minio-into-ck/status.sh

@@ -0,0 +1,25 @@
+#!/usr/bin/env bash
+set -e
+cat << 'LOGO'
+----------------------------------
+LOGO
+base_dir=$(
+    cd "$(dirname "$0")"
+    pwd
+)
+cd $base_dir
+server_pid=$(ps -auxc | grep minio-into-ck | grep -vE "grep|-Xmx700m" | awk '{print $2}')
+if [[ $server_pid == "" ]]; then
+    echo "minio-into-ck 未在运行"
+else
+    running_time=$(ps -o etime= -p "$server_pid")
+    ports=$(ss -tnlp | grep minio-into-ck | awk '{print $4}')
+
+    echo "minio-into-ck 当前PID: $server_pid"
+    echo "当前运行时间: $running_time" | tr -s " "
+    echo "当前运行端口:"
+    for i in "$ports"; do
+        echo "$i"
+	break
+    done
+fi

+ 53 - 0
minio-into-ck/stop.sh

@@ -0,0 +1,53 @@
+#!/usr/bin/env bash
+set +u
+set -e
+base_dir=$(
+    cd "$(dirname "$0")"
+    pwd
+)
+cd $base_dir
+if [[ $1 != "no_logo" ]]; then
+    cat << 'LOGO'
+###############################################################
+                         关闭服务脚本
+###############################################################
+LOGO
+else
+    shift 1
+fi
+# extra function
+## func of log
+function log_warn() {
+    local date=$(date "+%Y-%m-%d-%H:%M:%S")
+    local para=$1
+    echo "[WARN] $date $1" | tee -a "./log/stop_log"
+
+}
+
+function log_info() {
+    local date=$(date "+%Y-%m-%d-%H:%M:%S")
+    local para=$1
+    echo "[INFO] $date $1" | tee -a "./log/stop_log"
+}
+
+function log_err() {
+    local date=$(date "+%Y-%m-%d-%H:%M:%S")
+    local para=$1
+    echo "[ERROR] $date $1" | tee -a "./log/stop_log"
+}
+function stop_process() {
+    ID=$(ps -auxc | grep "$1" | grep -v "$0" | grep -v "grep" | awk '{print $2}')
+    if [[ "$ID" ]]; then
+        log_info "$1 运行中,准备关闭"
+        for id in $ID; do
+            kill -15 "$id"
+            echo "stop $1 process:(PID=${id})"
+        done
+        echo "---------------"
+    fi
+}
+
+if [[ -z $1 ]]; then
+    stop_process "minio-into-ck"
+    log_info "服务停止脚本运行完成"
+fi

+ 37 - 0
package.sh

@@ -0,0 +1,37 @@
+#!/bin/bash
+
+# set -e
+
+cur_date="`date +%Y-%m-%d`"
+ROOT=$(cd `dirname $0`; pwd)
+
+mkdir -p $ROOT/tmp
+rm -rf $ROOT/tmp/*
+
+# ----- Start build -----
+go build -o $ROOT/minio-into-ck/minio-into-ck $ROOT/
+
+cp -rf $ROOT/config $ROOT/minio-into-ck/
+# ----- End build -----
+
+cp -rf $ROOT/minio-into-ck $ROOT/tmp/
+cp -rf $ROOT/minio-into-ck-installer $ROOT/tmp/
+
+mkdir -p $ROOT/tmp/minio-into-ck/lib
+mkdir -p $ROOT/tmp/minio-into-ck/log
+
+cd $ROOT/tmp
+tar -zcf $ROOT/tmp/minio-into-ck-installer/minio-into-ck.tar.gz minio-into-ck
+
+cd $ROOT
+if [ ! -d "release" ]; then
+        mkdir -p release
+fi
+
+cd $ROOT/tmp
+tar -zcf $ROOT/release/minio-into-ck-installer-v${cur_date}.tar.gz minio-into-ck-installer
+
+rm -rf $ROOT/tmp/*
+rmdir $ROOT/tmp
+
+echo "打包成功"