mirror of
https://github.com/yavook/kiwi-scp.git
synced 2024-11-22 04:43:00 +00:00
Naming, format
This commit is contained in:
parent
c6fc48e849
commit
674547a83a
2 changed files with 22 additions and 27 deletions
|
@ -40,9 +40,9 @@ In some cases, notably when using a multi-version system such as
|
||||||
[CentOS SCL](https://wiki.centos.org/AdditionalResources/Repositories/SCL), not all of these are in your `$PATH`
|
[CentOS SCL](https://wiki.centos.org/AdditionalResources/Repositories/SCL), not all of these are in your `$PATH`
|
||||||
at login time.
|
at login time.
|
||||||
|
|
||||||
In those cases, you can simply create a `.kiwienv` file in your home directory.
|
In those cases, you can simply create a `.kiwi_profile` file in your home directory.
|
||||||
It will be sourced every time you use the `kiwi` command.
|
It will be sourced every time you use the `kiwi` command.
|
||||||
For the aforementioned case where you installed `centos-release-scl` and `rh-python36`, your `~/.kiwienv` should
|
For the aforementioned case where you installed `centos-release-scl` and `rh-python36`, your `~/.kiwi_profile` should
|
||||||
contain:
|
contain:
|
||||||
|
|
||||||
```shell script
|
```shell script
|
||||||
|
|
45
kiwi
45
kiwi
|
@ -10,11 +10,11 @@ KIWI_CONF_NAME="kiwi.yml"
|
||||||
KIWI_VERSION_TAG="etc/version_tag"
|
KIWI_VERSION_TAG="etc/version_tag"
|
||||||
|
|
||||||
# dependencies to run kiwi-scp
|
# dependencies to run kiwi-scp
|
||||||
KIWI_DEPS="python3 pipenv less docker docker-compose"
|
KIWI_DEPENDENCIES="python3 pipenv less docker docker-compose"
|
||||||
# base install dir
|
# base install dir
|
||||||
KIWI_BASEDIR="${HOME}/.local/lib/kiwi-scp"
|
KIWI_BASEDIR="${HOME}/.local/lib/kiwi-scp"
|
||||||
# per-user env setup script
|
# per-user env setup script
|
||||||
KIWI_ENVFILE="${HOME}/.kiwienv"
|
KIWI_PROFILE="${HOME}/.kiwi_profile"
|
||||||
|
|
||||||
# repository uri
|
# repository uri
|
||||||
KIWI_REPO="https://github.com/ldericher/kiwi-scp"
|
KIWI_REPO="https://github.com/ldericher/kiwi-scp"
|
||||||
|
@ -26,8 +26,7 @@ KIWI_URI="https://raw.githubusercontent.com/ldericher/kiwi-scp/master/kiwi"
|
||||||
INSTALLER_URI="https://raw.githubusercontent.com/ldericher/kiwi-scp/master/install.sh"
|
INSTALLER_URI="https://raw.githubusercontent.com/ldericher/kiwi-scp/master/install.sh"
|
||||||
# canary file: limit curl requests
|
# canary file: limit curl requests
|
||||||
CANARY_FILENAME="/var/lock/kiwi-scp.canary"
|
CANARY_FILENAME="/var/lock/kiwi-scp.canary"
|
||||||
CANARY_MAXAGE=600
|
CANARY_MAX_AGE=600
|
||||||
|
|
||||||
|
|
||||||
###################
|
###################
|
||||||
# DYNAMIC STRINGS #
|
# DYNAMIC STRINGS #
|
||||||
|
@ -39,13 +38,13 @@ kiwi_archive_uri() {
|
||||||
}
|
}
|
||||||
|
|
||||||
# directory of correct installation
|
# directory of correct installation
|
||||||
kiwi_installdir() {
|
kiwi_install_dir() {
|
||||||
echo "${KIWI_BASEDIR}/${KIWI_VERSION}"
|
echo "${KIWI_BASEDIR}/${KIWI_VERSION}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# src directory in installed version
|
# src directory in installed version
|
||||||
kiwi_root() {
|
kiwi_root() {
|
||||||
echo "$(kiwi_installdir)/src"
|
echo "$(kiwi_install_dir)/src"
|
||||||
}
|
}
|
||||||
|
|
||||||
# main script in installed version
|
# main script in installed version
|
||||||
|
@ -56,7 +55,6 @@ kiwi_executable() {
|
||||||
# cache current work directory
|
# cache current work directory
|
||||||
WORKDIR="$(pwd)"
|
WORKDIR="$(pwd)"
|
||||||
|
|
||||||
|
|
||||||
#############
|
#############
|
||||||
# FUNCTIONS #
|
# FUNCTIONS #
|
||||||
#############
|
#############
|
||||||
|
@ -78,30 +76,27 @@ yes_no() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
##################
|
##################
|
||||||
# PER-USER SETUP #
|
# PER-USER SETUP #
|
||||||
##################
|
##################
|
||||||
|
|
||||||
# add in environment setup
|
# add in environment setup
|
||||||
if [ -f "${KIWI_ENVFILE}" ]; then
|
if [ -f "${KIWI_PROFILE}" ]; then
|
||||||
# shellcheck source=$HOME/.kiwienv
|
# shellcheck source=$HOME/.kiwi_profile
|
||||||
. "${KIWI_ENVFILE}"
|
. "${KIWI_PROFILE}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
##########
|
##########
|
||||||
# CHECKS #
|
# CHECKS #
|
||||||
##########
|
##########
|
||||||
|
|
||||||
for dep in ${KIWI_DEPS}; do
|
for dep in ${KIWI_DEPENDENCIES}; do
|
||||||
if ! command -v "${dep}" >/dev/null 2>/dev/null; then
|
if ! command -v "${dep}" >/dev/null 2>/dev/null; then
|
||||||
echo "Dependency '${dep}' not found, please install!" >/dev/stderr
|
echo "Dependency '${dep}' not found, please install!" >/dev/stderr
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
########
|
########
|
||||||
# MAIN #
|
# MAIN #
|
||||||
########
|
########
|
||||||
|
@ -110,10 +105,10 @@ done
|
||||||
if [ -f "${CANARY_FILENAME}" ]; then
|
if [ -f "${CANARY_FILENAME}" ]; then
|
||||||
# check canary age
|
# check canary age
|
||||||
current_time="$(date '+%s')"
|
current_time="$(date '+%s')"
|
||||||
canary_mtime="$(date -r "${CANARY_FILENAME}" '+%s')"
|
canary_mod_time="$(date -r "${CANARY_FILENAME}" '+%s')"
|
||||||
canary_age="$(( current_time - canary_mtime ))"
|
canary_age="$((current_time - canary_mod_time))"
|
||||||
|
|
||||||
if [ ${canary_age} -gt ${CANARY_MAXAGE} ]; then
|
if [ ${canary_age} -gt ${CANARY_MAX_AGE} ]; then
|
||||||
# canary file too old!
|
# canary file too old!
|
||||||
run_kiwi_check="yes"
|
run_kiwi_check="yes"
|
||||||
fi
|
fi
|
||||||
|
@ -127,7 +122,7 @@ fi
|
||||||
# run check for new kiwi version
|
# run check for new kiwi version
|
||||||
if [ "${run_kiwi_check}" = "yes" ]; then
|
if [ "${run_kiwi_check}" = "yes" ]; then
|
||||||
# hash this script and the master version
|
# hash this script and the master version
|
||||||
hash_local="$(md5sum < "$(readlink "${0}")")"
|
hash_local="$(md5sum <"$(readlink "${0}")")"
|
||||||
hash_remote="$(curl --proto '=https' --tlsv1.2 -sSfL "${KIWI_URI}" | md5sum)"
|
hash_remote="$(curl --proto '=https' --tlsv1.2 -sSfL "${KIWI_URI}" | md5sum)"
|
||||||
|
|
||||||
# warn if different
|
# warn if different
|
||||||
|
@ -173,8 +168,8 @@ if [ ! -x "$(kiwi_executable)" ]; then
|
||||||
printf "Installing kiwi-scp v%s into %s ... " "${KIWI_VERSION}" "${KIWI_BASEDIR}"
|
printf "Installing kiwi-scp v%s into %s ... " "${KIWI_VERSION}" "${KIWI_BASEDIR}"
|
||||||
|
|
||||||
# switch to temp dir
|
# switch to temp dir
|
||||||
tmpdir=$(mktemp -d)
|
tmp_dir=$(mktemp -d)
|
||||||
cd "${tmpdir}" || :
|
cd "${tmp_dir}" || :
|
||||||
|
|
||||||
# download archive
|
# download archive
|
||||||
curl --proto '=https' --tlsv1.2 -sSfL "$(kiwi_archive_uri)" | tar xz
|
curl --proto '=https' --tlsv1.2 -sSfL "$(kiwi_archive_uri)" | tar xz
|
||||||
|
@ -189,14 +184,14 @@ if [ ! -x "$(kiwi_executable)" ]; then
|
||||||
|
|
||||||
else
|
else
|
||||||
# install archive
|
# install archive
|
||||||
mkdir -p "$(kiwi_installdir)"
|
mkdir -p "$(kiwi_install_dir)"
|
||||||
mv "src" "Pipfile" "Pipfile.lock" "$(kiwi_installdir)/"
|
mv "src" "Pipfile" "Pipfile.lock" "$(kiwi_install_dir)/"
|
||||||
echo "OK"
|
echo "OK"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# discard temp dir
|
# discard temp dir
|
||||||
cd "${WORKDIR}" || :
|
cd "${WORKDIR}" || :
|
||||||
rm -rf "${tmpdir}"
|
rm -rf "${tmp_dir}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# go back to the original work directory
|
# go back to the original work directory
|
||||||
|
@ -205,7 +200,7 @@ cd "${WORKDIR}" || :
|
||||||
# setup main environment
|
# setup main environment
|
||||||
KIWI_ROOT="$(kiwi_root)"
|
KIWI_ROOT="$(kiwi_root)"
|
||||||
PIPENV_VERBOSITY=-1
|
PIPENV_VERBOSITY=-1
|
||||||
PIPENV_PIPFILE="$(kiwi_installdir)/Pipfile"
|
PIPENV_PIPFILE="$(kiwi_install_dir)/Pipfile"
|
||||||
|
|
||||||
export KIWI_CONF_NAME
|
export KIWI_CONF_NAME
|
||||||
export KIWI_ROOT
|
export KIWI_ROOT
|
||||||
|
@ -213,7 +208,7 @@ export PIPENV_VERBOSITY
|
||||||
export PIPENV_PIPFILE
|
export PIPENV_PIPFILE
|
||||||
|
|
||||||
# check virtualenv
|
# check virtualenv
|
||||||
cd "$(kiwi_installdir)" || :
|
cd "$(kiwi_install_dir)" || :
|
||||||
if ! pipenv --venv >/dev/null 2>/dev/null; then
|
if ! pipenv --venv >/dev/null 2>/dev/null; then
|
||||||
# install virtualenv
|
# install virtualenv
|
||||||
printf "Preparing virtualenv ... "
|
printf "Preparing virtualenv ... "
|
||||||
|
|
Loading…
Reference in a new issue