美文网首页
如何远程执行github上的脚本

如何远程执行github上的脚本

作者: 国才大叔的小屋 | 来源:发表于2016-07-28 21:30 被阅读456次

           首先,我们需要从github上下载run这个工具,Run是开源的脚本管理工具,本身由go语言开发,Run项目地址,run可以远程执行python,shell等等,这些脚本可以放在以下代码托管平台。具体详细介绍,可以到官方项目地址查看。

    如何下载

          我们到项目地址,https://github.com/runscripts/run,直接下载Run的二进制包,如图,本次我下载的是linux平台64位的包。

    上传服务器

          使用rz命令,上传用浏览器下载好的Run的二进制包,我直接把它上传到了linux服务器的/usr/bin/下。没有rz命令,请尝试用yum安装lrzsz包。

    [root@pangu ~]# file /usr/bin/run

    /usr/bin/run: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), not stripped

          上传的Run已经编译,是一个单独可以执行的程序了,但是直接上传的Run是没有可执行的权限的。需要手动赋予Run权限。

    [root@pangu ~]# chmod +x  /usr/bin/run

    [root@pangu ~]# ll /usr/bin/run

    -rwxr-xr-x. 1 root root 5806368 Jul 25 11:48 /usr/bin/run

    使用命令run --init初始化一下环境,生成run的配置文件/etc/run.conf和run的文件锁和脚本下载目录/usr/local/run/default/。

    配置Run

    好了,我们可以敲一下run ,如果出现帮助信息,就说明run安装成功了。

    [root@pangu ~]# run 

    Usage:run   [OPTION] [SCOPE:]SCRIPT

    Options:

    -c, --clean    clean out all scripts cached in local

    -h, --help      show this help message, then exit

    -i INTERPRETER  run script with interpreter(e.g., bash, python)

    -I, --init      create configuration and cache directory

    -u, --update    force to update the script before run

    -v, --view      view the content of script, then exit

    -V, --version  output version information, then exit

    Examples:

    run pt-summary

    run github:runscripts/scripts/pt-summary

    我们可以使用官方提供的例子,执行一下run pt-summary试试,出来一堆收集到的系统信息。

    可以把官网的github地址替换成自己的github地址,当然必须是脚本的仓库,我这里填的是自己shell仓库的master分支下。这里注意真正的脚本文件是放在raw.githubusercontent.com,不是github.com/ZuoGuocai/BashShellScripts。看到的不一定是真实的。

    如果中途出错,需要手动清理一下缓存,run  -c,防止上次错误的执行,影响本次的执行,尤其是配置文件报错后,此命令很好用。

    首次尝试

    [root@pangu ~]# run heart.sh

    相关文章

      网友评论

          本文标题:如何远程执行github上的脚本

          本文链接:https://www.haomeiwen.com/subject/xogajttx.html