kind: ConfigMap
apiVersion: v1
metadata:
  name: fuse-install-deps-script
data:
  install_deps.sh: |-
    #!/usr/bin/env sh

    # See https://get.docker.com.
    get_distro() {
        distro=""
    	# Every system that we officially support has /etc/os-release
    	if [ -r /etc/os-release ]; then
    		distro="$(. /etc/os-release && echo "$ID")"
    	fi
    	# Returning an empty string here should be alright since the
    	# case statements don't act unless you provide an actual value
    	echo "$distro" | tr '[:upper:]' '[:lower:]'
    }


    run_debian() {
        apt-get update
        apt-get install -y fuse python3-pip git
        pip3 install git+git://github.com/met-office-lab/pysssix.git@big_cache
        curl -L -o /usr/bin/goofys http://bit.ly/goofys-latest
        chmod +x /usr/bin/goofys
    }


    run_amazonLinux() {
        yum update -y
        yum install -y fuse-devel fuse-libs fuse python3-pip git
        pip3 install git+git://github.com/met-office-lab/pysssix.git@big_cache
        curl -L -o /usr/bin/goofys http://bit.ly/goofys-latest
        chmod +x /usr/bin/goofys
    }


    distro=$(get_distro)

    case $distro in

        amzn)
            run_amazonLinux
        ;;

        debian)
            run_debian
        ;;

        *)
            echo "Unsupported distro"
            exit 1
        ;;

    esac

    exit 0
