diff --git a/.gitignore b/.gitignore index 96d153a8..b8fc6362 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,5 @@ __debug_bin /toughradius.yml /tmp/ /log_info.log -__debug_bin* \ No newline at end of file +__debug_bin* +.log \ No newline at end of file diff --git a/assets/buildinfo.txt b/assets/buildinfo.txt index 92dc13e0..7bd84dbc 100644 --- a/assets/buildinfo.txt +++ b/assets/buildinfo.txt @@ -1,8 +1,8 @@ -BuildVersion=latest v8.0.4 2024-01-18 15:23:34 +BuildVersion=latest v8.0.4 2024-01-27 21:39:08 ReleaseVersion=v8.0.4 -BuildTime=2024-01-18 15:23:34 +BuildTime=2024-01-27 21:39:08 BuildName=toughradius -CommitID=48ea29e6eddf11ce25e586beee529f51e5b5e85f -CommitDate=Wed, 10 Jan 2024 01:01:19 +0800 +CommitID=b67f7f938db96309ea71963e43aab88b2cc0c4d3 +CommitDate=Sat, 27 Jan 2024 21:37:48 +0800 CommitUser=jamiesun.net@gmail.com -CommitSubject=2024-01-10 01:01:08 : readme +CommitSubject=add installer.sh diff --git a/docs/documents/installer.md b/docs/documents/installer.md index bae84f74..7f105f8c 100644 --- a/docs/documents/installer.md +++ b/docs/documents/installer.md @@ -28,7 +28,7 @@ Download the software distribution from [Releases Page](https://github.com/talki > If you have some development skills, you can compile your own version ``` -curl https://github.com/talkincode/toughradius/releases/download/v8.0.4/toughradius_x86-64 -O /tmp/toughradius +curl https://github.com/talkincode/toughradius/releases/download/v8.0.6/toughradius_amd64 -O /tmp/toughradius chmod +x /tmp/toughradius && /tmp/toughradius -install @@ -39,10 +39,10 @@ Before proceeding, make sure that you have created the database and that the dat Modifying configuration file [/etc/toughradius.yml](Configuration.md) -> The following installation method will download and build the latest toughradius version (Support for v8.0.4 and later) +> The following installation method will download and build the latest toughradius version ```bash -go install github.com/talkincode/toughradius/v8@v8.0.4 +go install github.com/talkincode/toughradius/v8@latest toughradius -install ``` diff --git a/installer.sh b/installer.sh new file mode 100644 index 00000000..306a4a15 --- /dev/null +++ b/installer.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +# Check if Golang is installed +if command -v go &> /dev/null +then + # Check that the installed version of Golang is at least 1.21 + GO_VERSION=$(go version | cut -d " " -f3) + MIN_VERSION="go1.21" + + if [[ "$GO_VERSION" < "$MIN_VERSION" ]] + then + echo "Detected Go version $GO_VERSION. Upgrading to Go 1.21.6..." + wget https://go.dev/dl/go1.21.6.linux-amd64.tar.gz + rm -rf /usr/local/go && tar -C /usr/local -xzf go1.21.6.linux-amd64.tar.gz + else + echo "Detected Go version $GO_VERSION. No upgrade needed." + fi +else + echo "Go is not installed. Installing Go 1.21.6..." + wget https://go.dev/dl/go1.21.6.linux-amd64.tar.gz + rm -rf /usr/local/go && tar -C /usr/local -xzf go1.21.6.linux-amd64.tar.gz +fi + +# SET GOROOT AND GOPATH +export GOROOT=/usr/local/go +export GOPATH=$HOME/go +export PATH=$PATH:$GOROOT/bin:$GOPATH/bin + +# Installation ToughRADIUS +echo "Installing ToughRADIUS..." +go install github.com/talkincode/toughradius/v8@latest + +# Execute the ToughRADIUS installation command +echo "Running ToughRADIUS install command..." +toughradius -install + +echo "ToughRADIUS installation completed." diff --git a/installer/installer.go b/installer/installer.go index 5300d08e..9238cb6a 100644 --- a/installer/installer.go +++ b/installer/installer.go @@ -50,7 +50,10 @@ func InitConfig(config *config.AppConfig) error { func Install() error { if !common.FileExists("/etc/toughradius.yml") { - _ = InitConfig(config.DefaultAppConfig) + err := InitConfig(config.DefaultAppConfig) + if err != nil { + return err + } } // Get the absolute path of the currently executing file file, _ := exec.LookPath(os.Args[0])