refactor: update tianji reporter install script

This commit is contained in:
moonrailgun 2023-11-08 22:59:08 +08:00
parent 09ec432f16
commit 1314a73a51

View File

@ -54,12 +54,14 @@ function install_dependencies() {
function input_dsn() { function input_dsn() {
defaultServer="{{DEFAULT_SERVER}}" defaultServer="{{DEFAULT_SERVER}}"
read -p "${Info} Please input server url(default: $defaultWorkspace)" serverUrl echo -e "${Info} Please input server url, press enter use default value(default: $defaultServer)"
serverUrl=${serverUrl:$defaultWorkspace} read -re serverUrl
serverUrl=${serverUrl:-$defaultServer}
defaultWorkspace="{{DEFAULT_WORKSPACE}}" defaultWorkspace="{{DEFAULT_WORKSPACE}}"
read -p "${Info} Please input workspaceId(default: $defaultWorkspace)" workspace echo -e "${Info} Please input workspaceId, press enter use default value(default: $defaultWorkspace)"
workspace=${workspace:$defaultWorkspace} read -re workspace
workspace=${workspace:-$defaultWorkspace}
} }
service_conf=/usr/lib/systemd/system/tianji-reporter.service service_conf=/usr/lib/systemd/system/tianji-reporter.service
@ -68,7 +70,7 @@ function write_service() {
echo -e "${Info} Write to systemd configuration" echo -e "${Info} Write to systemd configuration"
cat >${service_conf} <<-EOF cat >${service_conf} <<-EOF
[Unit] [Unit]
Description=Tianji-Report Description=Tianji-Reporter
Documentation=https://github.com/msgbyte/tianji Documentation=https://github.com/msgbyte/tianji
After=network.target After=network.target
@ -134,7 +136,8 @@ function install_client() {
esac esac
echo -e "${Info} Downloading ${arch} binary file..." echo -e "${Info} Downloading ${arch} binary file..."
mkdir -p /usr/local/tianji/reporter/ mkdir -p /usr/local/tianji/reporter/
cd /tmp && wget "https://github.com/msgbyte/tianji/releases/latest/download/tianji-reporter-linux-${arch}" cd /tmp
wget --no-check-certificate "https://github.com/msgbyte/tianji/releases/latest/download/tianji-reporter-linux-${arch}"
mv tianji-reporter-linux-${arch} /usr/local/tianji/reporter/tianji-reporter mv tianji-reporter-linux-${arch} /usr/local/tianji/reporter/tianji-reporter
chmod +x /usr/local/tianji/reporter/tianji-reporter chmod +x /usr/local/tianji/reporter/tianji-reporter
enable_service enable_service