Skip to content

Commit

Permalink
Upgraded Ferret to 0.16.4
Browse files Browse the repository at this point in the history
  • Loading branch information
ziflex committed Jan 4, 2022
1 parent ca844d8 commit 70bb5b3
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 72 deletions.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,16 @@ GitHub
docker run -d -p 8080:8080 ghcr.io/montferret/worker
```

Alternatively, if you want to use your own version of Chrome, you can run the Worker locally:
Alternatively, if you want to use your own version of Chrome, you can run the Worker locally.

By installing the binary:

```shell
curl https://raw.githubusercontent.com/MontFerret/cli/master/install.sh | sh
worker
```

Or by building locally:

```sh
make
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/MontFerret/worker
go 1.17

require (
github.com/MontFerret/ferret v0.16.3
github.com/MontFerret/ferret v0.16.4
github.com/go-waitfor/waitfor v1.0.0
github.com/go-waitfor/waitfor-http v1.0.0
github.com/hashicorp/golang-lru v0.5.4
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
github.com/Masterminds/glide v0.13.2/go.mod h1:STyF5vcenH/rUqTEv+/hBXlSTo7KYwg2oc2f4tzPWic=
github.com/Masterminds/semver v1.4.2/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
github.com/Masterminds/vcs v1.13.0/go.mod h1:N09YCmOQr6RLxC6UNHzuVwAdodYbbnycGHSmwVJjcKA=
github.com/MontFerret/ferret v0.16.3 h1:jxm/k1KDmugyje4c5mVM3Tct2JJvjPaFKl/esiqgzVg=
github.com/MontFerret/ferret v0.16.3/go.mod h1:1/RHBJsdrV99phmnh+lLJsv665u2MPpfw1WDJHeaO5s=
github.com/MontFerret/ferret v0.16.4 h1:BzT5Zvyf2ZbUvmSyAMc6Vu8mvCtGjiFPi/6QL7KCOnY=
github.com/MontFerret/ferret v0.16.4/go.mod h1:1/RHBJsdrV99phmnh+lLJsv665u2MPpfw1WDJHeaO5s=
github.com/PuerkitoBio/goquery v1.8.0 h1:PJTF7AmFCFKk1N6V6jmKfrNH9tV5pNE6lZMkG0gta/U=
github.com/PuerkitoBio/goquery v1.8.0/go.mod h1:ypIiRMtY7COPGk+I/YbZLbxsxn9g5ejnI2HSMtkjZvI=
github.com/andybalholm/cascadia v1.3.1 h1:nhxRkql1kdYCc8Snf7D5/D3spOX+dBgjA6u8x004T2c=
Expand Down
99 changes: 31 additions & 68 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,51 +1,27 @@
#!/bin/bash

projectName="worker"
binName="worker"
name="Ferret Worker"
defaultLocation="/usr/local/bin"
defaultVersion="latest"
location=${WORKER_LOCATION:-$defaultLocation}
version=${WORKER_VERSION:-$defaultVersion}
location=${LOCATION:-$defaultLocation}
version=${VERSION:-$defaultVersion}

echo "Installing location $location"
# Copyright MontFerret Team 2020
version=$(curl -sI https://github.com/MontFerret/worker/releases/latest | grep location | awk -F"/" '{ printf "%s", $NF }' | tr -d '\r')
version=$(curl -sI https://github.com/MontFerret/$projectName/releases/latest | awk '{print tolower($0)}' | grep location: | awk -F"/" '{ printf "%s", $NF }' | tr -d '\r')
echo "Installing $name $version to $location"

if [ ! $version ]; then
echo "Failed while attempting to install ferret-worker. Please manually install:"
echo "Failed while attempting to install $name. Please manually install:"
echo ""
echo "1. Open your web browser and go to https://github.com/MontFerret/worker/releases"
echo "1. Open your web browser and go to https://github.com/MontFerret/$projectName/releases"
echo "2. Download the latest release for your platform."
echo "3. chmod +x ./ferret-worker"
echo "4. mv ./ferret-worker $location"
echo "3. chmod +x ./$projectName"
echo "4. mv ./$projectName $location"
exit 1
fi

hasCli() {
has=$(which ferret-worker)

if [ "$?" = "0" ]; then
echo
echo "You already have the ferret-worker!"
export n=5
echo "Overwriting in $n seconds... Press Control+C to cancel."
echo
sleep $n
fi

hasCurl=$(which curl)

if [ "$?" = "1" ]; then
echo "You need curl to use this script."
exit 1
fi

hasTar=$(which tar)

if [ "$?" = "1" ]; then
echo "You need tar to use this script."
exit 1
fi
}

checkHash(){
sha_cmd="sha256sum"

Expand All @@ -55,7 +31,7 @@ checkHash(){

if [ -x "$(command -v $sha_cmd)" ]; then

(cd $targetDir && curl -sSL $baseUrl/worker_checksums.txt | $sha_cmd -c >/dev/null)
(cd $targetDir && curl -sSL $baseUrl/$projectName_checksums.txt | $sha_cmd -c >/dev/null)
if [ "$?" != "0" ]; then
# rm $targetFile
echo "Binary checksum didn't match. Exiting"
Expand All @@ -66,7 +42,6 @@ checkHash(){

getPackage() {
uname=$(uname)
userid=$(id -u)

platform=""
case $uname in
Expand Down Expand Up @@ -97,49 +72,29 @@ getPackage() {
fi

suffix=$platform$arch
targetDir="/tmp/worker$suffix"

if [ "$userid" != "0" ]; then
targetDir="$(pwd)/worker$suffix"
fi
targetDir="/tmp/$projectName$suffix"

if [ ! -d $targetDir ]; then
mkdir $targetDir
fi

targetFile="$targetDir/worker"
targetFile="$targetDir/$binName"

if [ -e $targetFile ]; then
rm $targetFile
fi

echo

if [ $location = $defaultLocation ]; then
if [ "$userid" != "0" ]; then
echo
echo "========================================================="
echo "== As the script was run as a non-root user the =="
echo "== following commands may need to be run manually =="
echo "========================================================="
echo
echo " sudo cp $targetFile $location/ferret-worker"
echo " rm -rf $targetDir"
echo

exit 1
fi
fi

if [ ! -d $location ]; then
mkdir $location
fi

baseUrl=https://github.com/MontFerret/worker/releases/download/$version
url=$baseUrl/worker$suffix.tar.gz
baseUrl=https://github.com/MontFerret/$projectName/releases/download/$version
url=$baseUrl/$projectName$suffix.tar.gz
echo "Downloading package $url as $targetFile"

curl -sSL $url | tar xz -C $targetDir
curl -sSL $url

if [ "$?" != "0" ]; then
echo "Failed to download file"
Expand All @@ -150,22 +105,30 @@ getPackage() {

chmod +x $targetFile

echo "Download complete."
echo "Download complete"
echo "Unpacking the archive..."

tar xz -C $targetDir

if [ "$?" != "0" ]; then
echo "Failed to unpack the archive"
exit 1
fi

echo
echo "Attempting to move $targetFile to $location"
echo "Attempting to move $targetFile to ${location}..."

mv $targetFile "$location/ferret-worker"
mv $targetFile "$location/$binName"

if [ "$?" = "0" ]; then
echo "New version of ferret-worker installed to $location"
echo "New version of $name installed to $location"
fi

if [ -d $targetDir ]; then
rm -rf $targetDir
fi

"$location/ferret-worker" --version
"$location/$binName" version
}

hasCli
getPackage

0 comments on commit 70bb5b3

Please sign in to comment.