init
This commit is contained in:
commit
1b77233ab3
21
LICENSE
Normal file
21
LICENSE
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2019 Yige
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
25
README.md
Normal file
25
README.md
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# DC-Agent
|
||||||
|
|
||||||
|
## Guide
|
||||||
|
|
||||||
|
### Linux、FreeBSD、Darwin(Mac OS)
|
||||||
|
|
||||||
|
```shell
|
||||||
|
source <(curl -sL https://git.io/fj8OJ)
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
To **install** or **run** dc-agent, you can use the [install script][2] using cURL:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
|
||||||
|
```
|
||||||
|
|
||||||
|
or Wget:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
|
||||||
|
```
|
||||||
|
|
||||||
|
### Windows
|
||||||
|
|
121
setup.sh
Executable file
121
setup.sh
Executable file
@ -0,0 +1,121 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Check root
|
||||||
|
if [ `whoami` != "root" ];then
|
||||||
|
echo -e "\nYou need to be root to perform this command. \n"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
os=$(uname | tr '[:upper:]' '[:lower:]')
|
||||||
|
|
||||||
|
platform() {
|
||||||
|
local support_os=("darwin" "linux" "freebsd")
|
||||||
|
|
||||||
|
if [[ "$os" == ${support_os[0]} || "$os" == ${support_os[1]} || "$os" == ${support_os[2]} ]]
|
||||||
|
then
|
||||||
|
echo $os
|
||||||
|
else
|
||||||
|
echo "no"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
arch() {
|
||||||
|
local out="386"
|
||||||
|
local res=`uname -m`
|
||||||
|
|
||||||
|
case $res in
|
||||||
|
"x86_64") out="amd64"
|
||||||
|
;;
|
||||||
|
"x86") out="386"
|
||||||
|
;;
|
||||||
|
# "armv7l") out="armv7l"
|
||||||
|
# ;;
|
||||||
|
# "amd64") out="amd64"
|
||||||
|
# ;;
|
||||||
|
*) out=res
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
echo $out
|
||||||
|
}
|
||||||
|
|
||||||
|
getLatestVersion() {
|
||||||
|
local res=$(curl -s https://server-0.sercretcore.cn/api/download\?arch=`arch`\&platform=`platform`)
|
||||||
|
local status=$(echo "${res}" | grep -Eo '"status":.*?[^\\]' | sed 's/"status"://g')
|
||||||
|
|
||||||
|
if [ ${status} == 1 ]
|
||||||
|
then
|
||||||
|
local downloadURL=$(echo "${res}" | grep -Eo '"downloadURL":.*?[^\\]",' | sed 's/"downloadURL":"//g' | sed 's/",//g')
|
||||||
|
echo ${downloadURL}
|
||||||
|
else
|
||||||
|
echo "no"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
cmdhas() {
|
||||||
|
type "$1" > /dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
download() {
|
||||||
|
if cmdhas "curl"; then
|
||||||
|
sudo curl --compressed -q "$@"
|
||||||
|
elif cmdhas "wget"; then
|
||||||
|
# Emulate curl with wget
|
||||||
|
ARGS=$(echo "$*" | command sed -e 's/--progress-bar /--progress=bar /' \
|
||||||
|
-e 's/-L //' \
|
||||||
|
-e 's/--compressed //' \
|
||||||
|
-e 's/-I /--server-response /' \
|
||||||
|
-e 's/-s /-q /' \
|
||||||
|
-e 's/-o /-O /' \
|
||||||
|
-e 's/-C - /-c /')
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
eval sudo wget $ARGS
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
Install() {
|
||||||
|
downloadURL=`getLatestVersion`
|
||||||
|
echo ${downloadURL}
|
||||||
|
if [[ "${downloadURL}" != "no" ]]
|
||||||
|
then
|
||||||
|
mkdir -p /usr/local/dc-agent/bin
|
||||||
|
mkdir -p /usr/local/dc-agent/log
|
||||||
|
|
||||||
|
download "${downloadURL}" -o "/usr/local/dc-agent/bin/dc-agent"
|
||||||
|
|
||||||
|
chmod +x /usr/local/dc-agent/bin/dc-agent
|
||||||
|
sudo /usr/local/dc-agent/bin/dc-agent install
|
||||||
|
sudo /usr/local/dc-agent/bin/dc-agent start
|
||||||
|
else
|
||||||
|
echo -e "\nServer connection failed, please check your network connection.\n"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
Uninstall() {
|
||||||
|
sudo /usr/local/dc-agent/bin/dc-agent stop
|
||||||
|
sudo /usr/local/dc-agent/bin/dc-agent remove
|
||||||
|
|
||||||
|
PIDFILE="/var/run/dc-agent.pid"
|
||||||
|
|
||||||
|
if [ -f $PIDFILE ]; then
|
||||||
|
PID=$(cat $PIDFILE)
|
||||||
|
sudo kill -QUIT $PID
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Remove all file
|
||||||
|
sudo rm -rf /usr/local/dc-agent
|
||||||
|
|
||||||
|
echo -e "\nUninstall success!\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "What do you want to do?"
|
||||||
|
select var in "Install" "Uninstall" ; do
|
||||||
|
break;
|
||||||
|
done
|
||||||
|
echo "You have selected $var."
|
||||||
|
|
||||||
|
if [[ $var == "Install" ]]; then
|
||||||
|
Install
|
||||||
|
else
|
||||||
|
Uninstall
|
||||||
|
fi
|
Loading…
Reference in New Issue
Block a user