简体   繁体   中英

How to do auto upgrade to latest github software release version?

Releases uploads every time to url like https://github.com/ipfs/go-ipfs/releases/tag/v0.9.1

my script is

#!/bin/bash
rm /home/ipfs/go-ipfs -rf
rm go-ipfs.tar.gz
curl -s  https://api.github.com/repos/ipfs/go-ipfs/releases/latest | grep linux-amd64.tar.gz\" | grep download  | sed 's/.*: \"//g' | sed 's/\"//g' | wget -i - -O /home/ipfs/go-ipfs.tar.gz
if test -f /home/ipfs/go-ipfs.tar.gz then
        tar -xf /home/ipfs/go-ipfs.tar.g
        newsize=$(wc -c <"/home/ipfs/go-ipfs/ipfs")
        cursize=$(wc -c <"/home/ipfs/ipfs")
        if [$newsize -ne $cursize]; then
                mv /home/ipfs/go-ipfs/ipfs /home/ipfs/ipfs
                chmod +x /home/ipfs/ipfs
                pkill ipfs
        fi
fi

but it has an error i cant fix

Solution is

#!/bin/bash

#remove old repo folder
rm /home/ipfs/go-ipfs -rf

#remove old tar.gz
rm go-ipfs.tar.gz

#try to download new
curl -s  https://api.github.com/repos/ipfs/go-ipfs/releases/latest | grep linux-amd64.tar.gz\" | grep download  | sed 's/.*: \"//g' | sed 's/\"//g' | wget -i - -O /home/ipfs/go-ipfs.tar.gz

#check file exists
if [ -f /home/ipfs/go-ipfs.tar.gz ]; then
        #unpack tar gz
        tar -xf /home/ipfs/go-ipfs.tar.gz

        #get file sizes 
        newsize=$(wc -c <"/home/ipfs/go-ipfs/ipfs")
        cursize=$(wc -c <"/home/ipfs/ipfs")

        #if new file is not as current
        if (($newsize != $cursize)); then
                #replace it
                mv /home/ipfs/go-ipfs/ipfs /home/ipfs/ipfs
                chmod +x /home/ipfs/ipfs
                #kill old to restart new
                pkill ipfs
        fi
fi

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM