diff --git a/README.md b/README.md index 5c43234..2f99012 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,10 @@ This module can be used to quickly set up a CoLink protocol with just a few line ## Running a Protocol by Playbook -1. Download the release binary of your system from GitHub. +1. install the playbook from GitHub. ```bash - bash -c "$(curl -fsSL https://raw.githubusercontent.com/CoLearn-Dev/colink-playbook-dev/main/download.sh)" + bash -c "$(curl -fsSL https://raw.githubusercontent.com/CoLearn-Dev/colink-playbook-dev/main/install.sh)" ``` You can also build from source diff --git a/download.sh b/download.sh deleted file mode 100644 index f1837f1..0000000 --- a/download.sh +++ /dev/null @@ -1,11 +0,0 @@ -tag=$(wget -qO- -t1 -T2 "https://api.github.com/repos/CoLearn-Dev/colink-playbook-dev/releases/latest" | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g') -download_url=https://github.com/CoLearn-Dev/colink-playbook-dev/releases/download/${tag} -echo ${download_url} -if [ "$(uname)" == "Linux" ]; then - wget -O colink-playbook ${download_url}/colink-playbook-linux-x86_64 -elif [ "$(uname)" == "Darwin" ]; then - wget -O colink-playbook ${download_url}/colink-playbook-macos-x86_64 -else - echo "Unsupported operating system" >&2 - exit 1 -fi diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..3de4daf --- /dev/null +++ b/install.sh @@ -0,0 +1,26 @@ +tag=$(wget -qO- -t1 -T2 "https://api.github.com/repos/CoLearn-Dev/colink-playbook-dev/releases/latest" | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g') +download_url=https://github.com/CoLearn-Dev/colink-playbook-dev/releases/download/${tag} + +if [ -z $COLINK_HOME ]; then + COLINK_HOME="$HOME/.colink" +fi +mkdir -p $COLINK_HOME +echo "Install colink-playbook to $COLINK_HOME" + +PACKAGE_NAME="colink-playbook-linux-x86_64" +if [ "$(uname)" == "Darwin" ]; then + PACKAGE_NAME="colink-playbook-macos-x86_64" +fi + +URL="${download_url}/${PACKAGE_NAME}" +if command -v curl > /dev/null ; then + curl -fsSL $URL -o $COLINK_HOME/colink-playbook +elif command -v wget > /dev/null ; then + wget $URL -O $COLINK_HOME/colink-playbook +else + print_str "command not found: wget or curl" + exit 1 +fi + +chmod +x $COLINK_HOME/colink-playbook +echo "Install colink-playbook: done" \ No newline at end of file