瀏覽代碼

自动下载

黄宗银 3 年之前
父節點
當前提交
4909933bd9
共有 1 個文件被更改,包括 20 次插入0 次删除
  1. 20 0
      auto_update.bash

+ 20 - 0
auto_update.bash

@@ -0,0 +1,20 @@
+#!/bin/bash
+
+# 注意:不同shell对语法的支持有细微差别,第一行并不能随便写。
+
+SCRIPT_DIR=$(
+	cd $(dirname ${BASH_SOURCE[0]})
+	pwd
+)
+
+# 自动更新为最新版本
+ftag_name=$(curl -ksSL https://api.github.com/repos/RainLoop/rainloop-webmail/releases/latest | jq -r '.tag_name')
+fName="${SCRIPT_DIR}/rainloop-${ftag_name}.zip"
+
+if [ ! -e "${fName}" ]; then
+	curl -o ${fName} -ksSL $(curl -ksSL https://api.github.com/repos/RainLoop/rainloop-webmail/releases/latest | jq -r '.assets[0].browser_download_url')
+	rm -rf ${SCRIPT_DIR}/rainloop
+	rm -f ${SCRIPT_DIR}/index.php
+	unzip -n -d ${SCRIPT_DIR}/ ${fName}
+	chmod -R 777 ${SCRIPT_DIR}/rainloop
+fi