From eafc4ae55c374c9ff8f3ba8063db9987233096a2 Mon Sep 17 00:00:00 2001 From: ldericher Date: Mon, 24 Aug 2020 17:01:16 +0200 Subject: [PATCH] v0.0.1: First release, not expected to be fully functional --- README.md | 23 ++++++++++++ example/kiwi.yml | 2 +- install.sh | 85 +++++++++++++++++++++++++++++++++++++++++++++ kiwi | 61 +++++++++++--------------------- src/etc/version_tag | 2 +- 5 files changed, 130 insertions(+), 43 deletions(-) create mode 100644 README.md create mode 100755 install.sh diff --git a/README.md b/README.md new file mode 100644 index 0000000..b63427a --- /dev/null +++ b/README.md @@ -0,0 +1,23 @@ +# kiwi-config + +The simple tool for managing container servers + +## Quick start + +- Learn to use `docker` with `docker-compose` +- Install kiwi-config +- Look at [the example instance](../example) +- Look at the output of `kiwi --help` +- Start building your own instances + +## Installation + +```shell script +curl 'https://raw.githubusercontent.com/ldericher/kiwi-config/master/install.sh' | sh +``` + +That script checks for the basic dependencies of the `kiwi` command, then downloads the main script and installs it to a location of your choice. Please consider installing `kiwi` into a directory inside your $PATH. + +## Get started + +TODO diff --git a/example/kiwi.yml b/example/kiwi.yml index d8dab05..9965083 100644 --- a/example/kiwi.yml +++ b/example/kiwi.yml @@ -2,7 +2,7 @@ # kiwi-config instance configuration # ###################################### -version: '0.1' +version: '0.0.1' runtime: storage: /tmp/kiwi diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..3ee19c3 --- /dev/null +++ b/install.sh @@ -0,0 +1,85 @@ +#!/bin/sh + +############# +# CONSTANTS # +############# + +# dependencies to run kiwi-config +KIWI_DEPS="bash python3 pipenv less" + +########## +# CHECKS # +########## + +printf "checking dependencies ... " + +for dep in ${KIWI_DEPS}; do + printf "%s, " "${dep}" + + if ! command -v "${dep}" >/dev/null 2>/dev/null; then + echo + echo "Dependency '${dep}' not found, please install!" >/dev/stderr + exit 1 + fi +done + +echo "OK" + +######## +# MAIN # +######## + +# prompt for installation directory +install_dir_default="/usr/local/bin" +valid="no" + +while [ "${valid}" = "no" ]; do + printf "Select installation directory [Default: '%s']: " "${install_dir_default}" + read install_dir + install_dir="${install_dir:-${install_dir_default}}" + + # check + if [ -d "${install_dir}" ]; then + valid="yes" + + else + printf "Install directory doesn't exist. Try creating? [Y|n] " + read yesno + if [ ! "${yesno}" = "N" ] || [ ! "${yesno}" = "n" ]; then + + # check creation failure + if mkdir -p "${install_dir}"; then + valid="yes" + + else + echo "Invalid install directory." >/dev/stderr + exit 1 + fi + fi + fi +done + +# start actual installation +printf "Installing into '%s' ... " "${install_dir}" + +# install "kiwi" script +uri="https://raw.githubusercontent.com/ldericher/kiwi-config/master/kiwi" +tmp_file="$(mktemp)" + +if ! curl -o "${tmp_file}" "${uri}" >/dev/null 2>/dev/null; then + rm "${tmp_file}" + echo "Download 'kiwi' failed!" >/dev/stderr + exit 1 +fi + +if ! install -m 0755 "${tmp_file}" "${install_dir}/kiwi"; then + rm "${tmp_file}" + echo "Install 'kiwi' failed!" >/dev/stderr + exit 1 +fi + +rm "${tmp_file}" + +# finalization +echo "OK" +exit 0 \ No newline at end of file diff --git a/kiwi b/kiwi index 71f2382..e4cb044 100755 --- a/kiwi +++ b/kiwi @@ -10,9 +10,9 @@ KIWI_CONF_NAME="kiwi.yml" KIWI_VERSION_TAG="etc/version_tag" # dependencies to run kiwi-config -KIWI_DEPS=(python3 pipenv less docker docker-compose) +KIWI_DEPS=(docker docker-compose) # base install dir -KIWI_BASEDIR="${HOME}/.cache/kiwi-config" +KIWI_BASEDIR="${HOME}/.local/lib/kiwi-config" # per-user env setup script KIWI_ENVFILE="${HOME}/.kiwienv" @@ -59,7 +59,7 @@ fi for dep in "${KIWI_DEPS[@]}"; do if ! command -v "${dep}" &>/dev/null; then - echo "Dependency '${dep}' not found, please install!" + echo "Dependency '${dep}' not found, please install!" >/dev/stderr exit 1 fi done @@ -79,48 +79,27 @@ fi if [ ! -x "$(kiwi_executable)" ]; then echo -n "Installing kiwi-config v${KIWI_VERSION} into ${KIWI_BASEDIR} ... " - ### TODO: post-release version ### + # switch to temp dir + tmpdir=$(mktemp -d) + cd "${tmpdir}" || : - # # switch to temp dir - # tmpdir=$(mktemp -d) - # cd "${tmpdir}" || : + # download archive + curl -o "kiwi-config.zip" "${KIWI_REPO}/archive/${KIWI_VERSION}.zip" + unzip "kiwi-config.zip" - # # download archive - # wget "${KIWI_REPO}/archive/${KIWI_VERSION}.zip" - # unzip "${KIWI_VERSION}.zip" - - # # read archive version tag - # cd "kiwi-config-${KIWI_VERSION}" || : - # KIWI_VERSION=$(cat "./src/${KIWI_VERSION_TAG}") - - # # install archive - # mkdir -p "$(kiwi_installdir)" - # mv "src" "Pipfile" "Pipfile.lock" "$(kiwi_installdir)/" - - # # discard temp dir - # cd "${WORKDIR}" || : - # rm -rf "${tmpdir}" - - # echo "OK" - - ### pre-release version ### - - # use this directory as archive - cd "$(dirname "$(readlink -f "${0}")")" || : - - # read this version tag + # read archive version tag + cd "kiwi-config-${KIWI_VERSION}" || : KIWI_VERSION=$(cat "./src/${KIWI_VERSION_TAG}") - if [ -x "$(kiwi_executable)" ]; then - # after version update: no need to install - echo "kiwi-config v${KIWI_VERSION} found!" - else - # install this - mkdir -p "${KIWI_BASEDIR}" - ln -s "$(readlink -f .)" "$(kiwi_installdir)" - # cd - echo "OK" - fi + # install archive + mkdir -p "$(kiwi_installdir)" + mv "src" "Pipfile" "Pipfile.lock" "$(kiwi_installdir)/" + + # discard temp dir + cd "${WORKDIR}" || : + rm -rf "${tmpdir}" + + echo "OK" fi # check virtualenv diff --git a/src/etc/version_tag b/src/etc/version_tag index ceab6e1..8a9ecc2 100644 --- a/src/etc/version_tag +++ b/src/etc/version_tag @@ -1 +1 @@ -0.1 \ No newline at end of file +0.0.1 \ No newline at end of file