sh Bash |从Github存储库安装可执行文件(tar.gz)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh Bash |从Github存储库安装可执行文件(tar.gz)相关的知识,希望对你有一定的参考价值。

# This script will allow you to create an installation script, which will download a release from a GitHub repository,
# and install it on /usr/local/bin, accessible by user's PATH. The release file should include an executable, without any
# subfolders. After tweaking this file, you may now add it to your
# repository at your root as `install.sh` in the master branch. Users may run this script with:
#
#  curl -s https://raw.githubusercontent.com/<user>/<repo>/master/install.sh | sh
#

# Custom configuration

github_release_filename="<your release filename>.tar.gz"
github_release_version_tag="v0.0.1"
github_user="<username>"
github_repo="<repository name>"
executable_name="<your executable file inside your compressed package>"
executable_target_folder="/usr/local/bin"

# -----------------------

# Fixed variables.
download_url="https://github.com/$github_user/$github_repo/releases/download/$github_release_version_tag/$github_release_filename"
tmp_file="tmp/$github_release_filename"
executable_path="$executable_target_folder/$executable_name"

# Download the compressed file.
echo "Downloading $github_user/$github_repo $github_release_version_tag from $download_url ..."
curl -L -o $tmp_file $download_url

# Extract its content.
echo "Extracting executable into $executable_target_folder ..."
sudo tar -xvzf $tmp_file -C $executable_target_folder >> /dev/null

# Add executable permissions.
echo "Adding executable permissions to $executable_path ..."
sudo chmod +x $executable_path

# After install content (run help or man).
echo "Done! $github_user/$github_repo is now installed."
printf "\n\n"
$executable_name --help

以上是关于sh Bash |从Github存储库安装可执行文件(tar.gz)的主要内容,如果未能解决你的问题,请参考以下文章

Linux shell 脚本

sh su GitHub(从给定用户下载所有存储库)

sh 使用cURL从命令行创建新的Github存储库

sh 简单的bash脚本用于从mac App Sierra创建可启动ISO从Mac App Store安装映像

JUMPSERVER----一键安装

JUMPSERVER----一键安装