Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install script fails at line 7 'dirname' #104

Open
NCVito opened this issue Jul 27, 2023 · 11 comments
Open

Install script fails at line 7 'dirname' #104

NCVito opened this issue Jul 27, 2023 · 11 comments

Comments

@NCVito
Copy link

NCVito commented Jul 27, 2023

When attempting to run the install script on my linux server. I am immediately seeing this error:

dirname: missing operand

Am I the only one?

@skuzakov
Copy link

I have the same issue((

@CaptainPalapa
Copy link

Same here. Unfortunately, a Linux noob, so... likely beyond my (immediate) ability to correct. Debian Bullseye.

@pein95
Copy link

pein95 commented Aug 9, 2023

Same error

@nradchenko
Copy link

See #97

@Husky110
Copy link

Husky110 commented Oct 3, 2023

@nradchenko
#97 does not fix the missing operant-problem on dirname (at least not on ubuntu 22.04)

@ghost
Copy link

ghost commented Nov 3, 2023

Is there already a solution to the problem?

@Hypnocrit
Copy link

The author had a proposed fix but never posted it through. Its been 6 months.
https://github.com/MatchbookLab/local-persist/pull/98/files

Download the command to a file, set it executable then update the file per the diff and you should be off to the races.

In my case I have this part of an automated build system for dev environments in Vagrant. My solution is just to not download random bash scripts on the internet and then use sudo and hard code the file locally.

It's working for me now.

@kevindelord
Copy link

I have the issue as well

@mkrimm
Copy link

mkrimm commented Feb 24, 2024

The same for me

@michelbarnich
Copy link

michelbarnich commented Feb 28, 2024

I fixed the issue by replacing $BASH_SOURCE with $0 and using the script from #98 to look like this:

#!/usr/bin/env bash

set -e

VERSION="v1.3.0"

gitDir=$(realpath `dirname $0`/..)
echo $gitDir

# uname -s, uname -m
# Deb 32: Linux i686
# Ubuntu 64: Linux x86_64
# FreeBSD: FreeBSD amd64

if [[ "$UID" != 0 ]]; then
    echo NOTE: sudo needed to set up and run start service
    exit 1
fi


if [[ `git -C "${gitDir}" rev-parse --is-inside-work-tree 2> /dev/null` == "true" ]]; then
    thisGit=`git -C "${gitDir}" config --get remote.origin.url`
    thisGit=${thisGit::-4}
    GITHUB_BINARY_BASE="${thisGit}/releases/download"
    GITHUB_RAW_BASE="${thisGit/github.com/raw.githubusercontent.com}/releases/download"
fi

if [[ $thisGit == "" ]]; then
    GITHUB_URL_PARTS="MatchbookLab/local-persist"
    GITHUB_BINARY_BASE="https://github.com/${GITHUB_URL_PARTS}/releases/download"
    GITHUB_RAW_BASE="https://raw.githubusercontent.com/${GITHUB_URL_PARTS}/"
    GITHUB_URL_PARTS=
fi


function setenv {
    OS=$(uname -s | tr "[:upper:]" "[:lower:]")
    ARCH=$(uname -m)

    SUPPORTED=false
    if [[ $OS == "linux" ]]; then
        case $ARCH in
            "x86_64")
                ARCH="amd64"
                SUPPORTED=true
            ;;
            "aarch64")
                ARCH="arm64"
                SUPPORTED=true
            ;;
            "i686")
                # ARCH="386"
                SUPPORTED=false
            ;;
            # untested
            arm*)
                # ARCH="arm"
                SUPPORTED=false
            ;;
        esac
    elif [[ $OS == 'freebsd' ]]; then
        ARCH=$(uname -m)
        SUPPORTED=false
    fi

    if [[ $SUPPORTED == false ]]; then
        echo $OS $ARCH is not supported
        exit 2
    fi
}

function install-binary {
    echo Stopping docker-volume-local-persist service if running
    echo ''
    if [[ $* == *--upstart* ]]; then
        (sudo service docker-volume-local-persist stop || true)
    else
        (sudo systemctl stop docker-volume-local-persist || true)
    fi

    BINARY_URL="${GITHUB_BINARY_BASE}/${VERSION}/local-persist-${OS}-${ARCH}"
    BINARY_DEST="/usr/bin/docker-volume-local-persist"

    echo Downloading binary:
    echo "  From: $BINARY_URL"
    echo "  To:   $BINARY_DEST"

    curl -fLsS "$BINARY_URL" > $BINARY_DEST
    chmod +x $BINARY_DEST

    echo Binary download
    echo ''
}

# Systemd (default)
function setup-systemd {
    SYSTEMD_CONFIG_URL="${GITHUB_RAW_BASE}/${VERSION}/init/systemd.service"
    SYSTEMD_CONFIG_DEST="/etc/systemd/system/docker-volume-local-persist.service"

    echo Downloading Systemd service conf:
    echo "  From: $SYSTEMD_CONFIG_URL"
    echo "  To:   $SYSTEMD_CONFIG_DEST"

    sudo curl -fLsS "$SYSTEMD_CONFIG_URL" > $SYSTEMD_CONFIG_DEST

    echo Systemd conf downloaded
    echo ''
}

function start-systemd {
    echo Starting docker-volume-local-persist service...

    sudo systemctl daemon-reload
    sudo systemctl enable docker-volume-local-persist
    sudo systemctl start docker-volume-local-persist
    sudo systemctl status --full --no-pager docker-volume-local-persist

    echo ''
    echo Done! If you see this message, that should mean everything is installed and is running.
}

# Upstart
function setup-upstart {
    UPSTART_CONFIG_URL="${GITHUB_RAW_BASE}/${VERSION}/init/upstart.conf"
    UPSTART_CONFIG_DEST="/etc/init/docker-volume-local-persist.conf"

    echo Downloading binary:
    echo "  From: $UPSTART_CONFIG_URL"
    echo "  To:   $UPSTART_CONFIG_DEST"

    sudo curl -fLsS "$UPSTART_CONFIG_URL" > $UPSTART_CONFIG_DEST

    echo Upstart conf downloaded
    echo ''
}

function start-upstart {
    echo Reloading Upstart config and starting docker-volume-local-persist service...

    sudo initctl reload-configuration
    sudo service docker-volume-local-persist start
    sudo service docker-volume-local-persist status

    echo ''
    echo Done! If you see this message, that should mean everything is installed and is running.
}


setenv

if [[ $* == *--upstart* ]]; then
    install-binary --upstart
    setup-upstart
    start-upstart
else
    install-binary
    setup-systemd
    start-systemd
fi

This worked for me on Ubuntu 22.04.4

@Arcau
Copy link

Arcau commented Oct 4, 2024

this is still failing for me even after forking it and using the above - on ubuntu 22.04 also

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests