-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from csvwolf/feat/install.sh
feat: install.sh
- Loading branch information
Showing
9 changed files
with
134 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,4 @@ | |
config.json | ||
.idea | ||
dist/ | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
FROM golang:1.21.0 | ||
FROM ubuntu:latest | ||
|
||
VOLUME $HOME/.hostker/ddns_config.yaml | ||
VOLUME /root/.hostker | ||
## 安装依赖 | ||
RUN apt-get update && \ | ||
apt-get install -y curl | ||
|
||
RUN go get github.com/csvwolf/hostker-ddns | ||
ENTRYPOINT hostker-ddns start | ||
RUN curl -o /tmp/install.sh -L https://raw.githubusercontent.com/csvwolf/hostker-ddns/master/install.sh && \ | ||
chmod +x /tmp/install.sh && \ | ||
/tmp/install.sh | ||
ENTRYPOINT ["hostker-ddns", "start"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
#/bin/bash | ||
|
||
go build -ldflags "-X main.version=$(git describe --tags --abbrev=0)" | ||
go build -ldflags "-X github.com/csvwolf/hostker-ddns/command.version=$(git describe --tags --abbrev=0)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package command | ||
|
||
import ( | ||
"fmt" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var version = "unknown" | ||
|
||
var VersionCmd = &cobra.Command{ | ||
Use: "version", | ||
Short: "Print hostker-ddns version", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
fmt.Println("Hostker-DDNS version: ", version) | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/bin/bash | ||
|
||
# 检测操作系统类型 | ||
unameOut="$(uname -s)" | ||
case "${unameOut}" in | ||
Linux*) machine=Linux;; | ||
Darwin*) machine=Mac;; | ||
CYGWIN*) machine=Cygwin;; | ||
MINGW*) machine=MinGw;; | ||
*) machine="UNKNOWN:${unameOut}" | ||
esac | ||
|
||
# 检测机器架构 | ||
machineArch="$(uname -m)" | ||
case "${machineArch}" in | ||
armv6l) arch=arm64;; | ||
armv7l) arch=arm64;; | ||
aarch64) arch=arm64;; | ||
x86) arch=x86_64;; | ||
x86_64) arch=x86_64;; | ||
i386) arch=i386;; | ||
*) arch="UNKNOWN:${machineArch}" | ||
esac | ||
|
||
# 根据操作系统和架构选择对应的下载链接 | ||
fileName="" | ||
case "${machine}" in | ||
Linux) | ||
case "${arch}" in | ||
arm64) fileName="hostker-ddns_Linux_arm64.tar.gz";; | ||
x86_64) fileName="hostker-ddns_Linux_x86_64.tar.gz";; | ||
i386) fileName="hostker-ddns_Linux_i386.tar.gz";; | ||
*) echo "不支持的架构:${arch}" && exit 1;; | ||
esac | ||
;; | ||
Mac) | ||
case "${arch}" in | ||
arm64) fileName="hostker-ddns_Darwin_arm64.tar.gz";; | ||
x86_64) fileName="hostker-ddns_Darwin_x86_64.tar.gz";; | ||
*) echo "不支持的架构:${arch}" && exit 1;; | ||
esac | ||
;; | ||
*) | ||
echo "不支持的操作系统:${machine}" && exit 1;; | ||
esac | ||
|
||
# 下载安装包 | ||
echo "正在下载安装包...${fileName}" | ||
mkdir -p tmp | ||
curl -sL "https://github.com/csvwolf/hostker-ddns/releases/latest/download/${fileName}" | tar -xzf - -C ./tmp | ||
chmod +x tmp/hostker-ddns # 赋予可执行权限 | ||
mv ./tmp/hostker-ddns /usr/local/bin/ | ||
rm -rf tmp | ||
# 完成安装 | ||
echo "安装完成!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters