mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-28 03:26:45 +00:00
Installer fixes (#3962)
* Switch variable to make it easier to debug Fixes #3933 * rename output file * add setting to directly generate refs * use prod mode * fix check * add debug flags * remove debug marker * pre-safe keys * update installer ref * split installer steps * split steps further * try static adding * remove split key add * try dry rn again * do not dry run keys * fix debian 11 detection * add ci to let install run through * remove flags * remove dryrun * run on master * query api on test * fix missing env * use matmair for tests * use specific version * remove old python first * check python version * add more version checks * multiline marker for action * add option to select python env * set python version before running installer * cleanup script * use inline apt for python install * package 3.9 by default * remove custom python install * add some sleeps * fix package names * reduce double depb definition * set python version * remove 3.9 requirement * do invoke and wheel install in the right context * fix typing for 3.8 * use var for config file if it exsists * fix discovery * use raw output for jq * remove tests * revert change in tasks.py
This commit is contained in:
parent
798e95910c
commit
a2abdc297b
45
.pkgr.yml
45
.pkgr.yml
@ -15,33 +15,20 @@ env:
|
|||||||
- INVENTREE_PLUGIN_FILE=/opt/inventree/plugins.txt
|
- INVENTREE_PLUGIN_FILE=/opt/inventree/plugins.txt
|
||||||
- INVENTREE_CONFIG_FILE=/opt/inventree/config.yaml
|
- INVENTREE_CONFIG_FILE=/opt/inventree/config.yaml
|
||||||
after_install: contrib/packager.io/postinstall.sh
|
after_install: contrib/packager.io/postinstall.sh
|
||||||
|
dependencies:
|
||||||
|
- curl
|
||||||
|
- python3
|
||||||
|
- python3-venv
|
||||||
|
- python3-pip
|
||||||
|
- python3-cffi
|
||||||
|
- python3-brotli
|
||||||
|
- python3-wheel
|
||||||
|
- libpango-1.0-0
|
||||||
|
- libharfbuzz0b
|
||||||
|
- libpangoft2-1.0-0
|
||||||
|
- gettext
|
||||||
|
- nginx
|
||||||
|
- jq
|
||||||
targets:
|
targets:
|
||||||
ubuntu-20.04:
|
ubuntu-20.04: true
|
||||||
dependencies:
|
debian-11: true
|
||||||
- curl
|
|
||||||
- python3
|
|
||||||
- python3-venv
|
|
||||||
- python3-pip
|
|
||||||
- python3-cffi
|
|
||||||
- python3-brotli
|
|
||||||
- python3-wheel
|
|
||||||
- libpango-1.0-0
|
|
||||||
- libharfbuzz0b
|
|
||||||
- libpangoft2-1.0-0
|
|
||||||
- gettext
|
|
||||||
- nginx
|
|
||||||
- jq
|
|
||||||
debian-11:
|
|
||||||
dependencies:
|
|
||||||
- curl
|
|
||||||
- python3
|
|
||||||
- python3-venv
|
|
||||||
- python3-pip
|
|
||||||
- python3-cffi
|
|
||||||
- python3-brotli
|
|
||||||
- python3-wheel
|
|
||||||
- libpango-1.0-0
|
|
||||||
- libpangoft2-1.0-0
|
|
||||||
- gettext
|
|
||||||
- nginx
|
|
||||||
- jq
|
|
||||||
|
@ -2,16 +2,12 @@
|
|||||||
# This script was generated by bashly 0.8.9 (https://bashly.dannyb.co)
|
# This script was generated by bashly 0.8.9 (https://bashly.dannyb.co)
|
||||||
# Modifying it manually is not recommended
|
# Modifying it manually is not recommended
|
||||||
|
|
||||||
# :wrapper.bash3_bouncer
|
|
||||||
if [[ "${BASH_VERSINFO:-0}" -lt 4 ]]; then
|
if [[ "${BASH_VERSINFO:-0}" -lt 4 ]]; then
|
||||||
printf "bash version 4 or higher is required\n" >&2
|
printf "bash version 4 or higher is required\n" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# :command.master_script
|
|
||||||
# :command.root_command
|
|
||||||
root_command() {
|
root_command() {
|
||||||
# src/root_command.sh
|
|
||||||
# Settings
|
# Settings
|
||||||
source_url=${args[source]}
|
source_url=${args[source]}
|
||||||
publisher=${args[publisher]}
|
publisher=${args[publisher]}
|
||||||
@ -59,25 +55,26 @@ root_command() {
|
|||||||
# Check if os and version is supported
|
# Check if os and version is supported
|
||||||
get_distribution
|
get_distribution
|
||||||
echo "### Detected distribution: $OS $VER"
|
echo "### Detected distribution: $OS $VER"
|
||||||
NOT_SUPPORTED=false
|
SUPPORTED=true
|
||||||
case "$OS" in
|
case "$OS" in
|
||||||
Ubuntu)
|
Ubuntu)
|
||||||
if [[ $VER != "20.04" ]]; then
|
if [[ $VER != "20.04" ]]; then
|
||||||
NOT_SUPPORTED=true
|
SUPPORTED=false
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
Debian | Raspbian)
|
"Debian GNU/Linux" | Raspbian)
|
||||||
if [[ $VER != "11" ]]; then
|
if [[ $VER != "11" ]]; then
|
||||||
NOT_SUPPORTED=true
|
SUPPORTED=false
|
||||||
fi
|
fi
|
||||||
|
OS=Debian
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "### Distribution not supported"
|
echo "### Distribution not supported"
|
||||||
NOT_SUPPORTED=true
|
SUPPORTED=false
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [[ $NOT_SUPPORTED ]]; then
|
if [[ $SUPPORTED != "true" ]]; then
|
||||||
echo "This OS is currently not supported"
|
echo "This OS is currently not supported"
|
||||||
echo "please install manually using https://inventree.readthedocs.io/en/stable/start/install/"
|
echo "please install manually using https://inventree.readthedocs.io/en/stable/start/install/"
|
||||||
echo "or check https://github.com/inventree/InvenTree/issues/3836 for packaging for your OS."
|
echo "or check https://github.com/inventree/InvenTree/issues/3836 for packaging for your OS."
|
||||||
@ -96,11 +93,10 @@ root_command() {
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "### Adding key and package source"
|
echo "### Getting and adding key"
|
||||||
# Add key
|
wget -qO- https://dl.packager.io/srv/$publisher/InvenTree/key | sudo apt-key add -
|
||||||
do_call "wget -qO- https://dl.packager.io/srv/$publisher/InvenTree/key | sudo apt-key add -"
|
echo "### Adding package source"
|
||||||
# Add packagelist
|
do_call "sudo wget -O /etc/apt/sources.list.d/inventree.list https://dl.packager.io/srv/$publisher/InvenTree/$source_url/installer/${OS,,}/${VER}.repo"
|
||||||
do_call "sudo wget -O /etc/apt/sources.list.d/inventree.list https://dl.packager.io/srv/$publisher/InvenTree/$source_url/installer/${lsb_dist}/${dist_version}.repo"
|
|
||||||
|
|
||||||
echo "### Updateing package lists"
|
echo "### Updateing package lists"
|
||||||
do_call "sudo apt-get update"
|
do_call "sudo apt-get update"
|
||||||
@ -118,34 +114,30 @@ root_command() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# :command.version_command
|
|
||||||
version_command() {
|
version_command() {
|
||||||
echo "$version"
|
echo "$version"
|
||||||
}
|
}
|
||||||
|
|
||||||
# :command.usage
|
install.sh_usage() {
|
||||||
install_usage() {
|
|
||||||
if [[ -n $long_usage ]]; then
|
if [[ -n $long_usage ]]; then
|
||||||
printf "install - Interactive installer for InvenTree\n"
|
printf "install.sh - Interactive installer for InvenTree\n"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
else
|
else
|
||||||
printf "install - Interactive installer for InvenTree\n"
|
printf "install.sh - Interactive installer for InvenTree\n"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf "Usage:\n"
|
printf "Usage:\n"
|
||||||
printf " install [SOURCE] [PUBLISHER] [OPTIONS]\n"
|
printf " install.sh [SOURCE] [PUBLISHER] [OPTIONS]\n"
|
||||||
printf " install --help | -h\n"
|
printf " install.sh --help | -h\n"
|
||||||
printf " install --version | -v\n"
|
printf " install.sh --version | -v\n"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
# :command.long_usage
|
|
||||||
if [[ -n $long_usage ]]; then
|
if [[ -n $long_usage ]]; then
|
||||||
printf "Options:\n"
|
printf "Options:\n"
|
||||||
|
|
||||||
# :command.usage_fixed_flags
|
|
||||||
echo " --help, -h"
|
echo " --help, -h"
|
||||||
printf " Show this help\n"
|
printf " Show this help\n"
|
||||||
echo
|
echo
|
||||||
@ -153,34 +145,27 @@ install_usage() {
|
|||||||
printf " Show version number\n"
|
printf " Show version number\n"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
# :command.usage_flags
|
|
||||||
# :flag.usage
|
|
||||||
echo " --no-call, -n"
|
echo " --no-call, -n"
|
||||||
printf " Do not call outside APIs (only functionally needed)\n"
|
printf " Do not call outside APIs (only functionally needed)\n"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
# :flag.usage
|
|
||||||
echo " --dry-run, -d"
|
echo " --dry-run, -d"
|
||||||
printf " Dry run (do not install anything)\n"
|
printf " Dry run (do not install anything)\n"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
# :command.usage_args
|
|
||||||
printf "Arguments:\n"
|
printf "Arguments:\n"
|
||||||
|
|
||||||
# :argument.usage
|
|
||||||
echo " SOURCE"
|
echo " SOURCE"
|
||||||
printf " Package source that should be used\n"
|
printf " Package source that should be used\n"
|
||||||
printf " Allowed: stable, master, main\n"
|
printf " Allowed: stable, master, main\n"
|
||||||
printf " Default: stable\n"
|
printf " Default: stable\n"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
# :argument.usage
|
|
||||||
echo " PUBLISHER"
|
echo " PUBLISHER"
|
||||||
printf " Publisher that should be used\n"
|
printf " Publisher that should be used\n"
|
||||||
printf " Default: inventree\n"
|
printf " Default: inventree\n"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
# :command.usage_examples
|
|
||||||
printf "Examples:\n"
|
printf "Examples:\n"
|
||||||
printf " install\n"
|
printf " install\n"
|
||||||
printf " install master --no-call\n"
|
printf " install master --no-call\n"
|
||||||
@ -190,7 +175,6 @@ install_usage() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# :command.normalize_input
|
|
||||||
normalize_input() {
|
normalize_input() {
|
||||||
local arg flags
|
local arg flags
|
||||||
|
|
||||||
@ -214,7 +198,7 @@ normalize_input() {
|
|||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
# :command.inspect_args
|
|
||||||
inspect_args() {
|
inspect_args() {
|
||||||
readarray -t sorted_keys < <(printf '%s\n' "${!args[@]}" | sort)
|
readarray -t sorted_keys < <(printf '%s\n' "${!args[@]}" | sort)
|
||||||
if (( ${#args[@]} )); then
|
if (( ${#args[@]} )); then
|
||||||
@ -234,11 +218,8 @@ inspect_args() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# :command.command_functions
|
|
||||||
|
|
||||||
# :command.parse_requirements
|
|
||||||
parse_requirements() {
|
parse_requirements() {
|
||||||
# :command.fixed_flags_filter
|
|
||||||
case "${1:-}" in
|
case "${1:-}" in
|
||||||
--version | -v )
|
--version | -v )
|
||||||
version_command
|
version_command
|
||||||
@ -247,31 +228,26 @@ parse_requirements() {
|
|||||||
|
|
||||||
--help | -h )
|
--help | -h )
|
||||||
long_usage=yes
|
long_usage=yes
|
||||||
install_usage
|
install.sh_usage
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# :command.command_filter
|
|
||||||
action="root"
|
action="root"
|
||||||
|
|
||||||
# :command.parse_requirements_while
|
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
key="$1"
|
key="$1"
|
||||||
case "$key" in
|
case "$key" in
|
||||||
# :flag.case
|
|
||||||
--no-call | -n )
|
--no-call | -n )
|
||||||
|
|
||||||
# :flag.case_no_arg
|
|
||||||
args[--no-call]=1
|
args[--no-call]=1
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
|
||||||
# :flag.case
|
|
||||||
--dry-run | -d )
|
--dry-run | -d )
|
||||||
|
|
||||||
# :flag.case_no_arg
|
|
||||||
args[--dry-run]=1
|
args[--dry-run]=1
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
@ -282,8 +258,7 @@ parse_requirements() {
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
* )
|
* )
|
||||||
# :command.parse_requirements_case
|
|
||||||
# :command.parse_requirements_case_simple
|
|
||||||
if [[ -z ${args[source]+x} ]]; then
|
if [[ -z ${args[source]+x} ]]; then
|
||||||
|
|
||||||
args[source]=$1
|
args[source]=$1
|
||||||
@ -302,11 +277,9 @@ parse_requirements() {
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
# :command.default_assignments
|
|
||||||
[[ -n ${args[source]:-} ]] || args[source]="stable"
|
[[ -n ${args[source]:-} ]] || args[source]="stable"
|
||||||
[[ -n ${args[publisher]:-} ]] || args[publisher]="inventree"
|
[[ -n ${args[publisher]:-} ]] || args[publisher]="inventree"
|
||||||
|
|
||||||
# :command.whitelist_filter
|
|
||||||
if [[ ! ${args[source]} =~ ^(stable|master|main)$ ]]; then
|
if [[ ! ${args[source]} =~ ^(stable|master|main)$ ]]; then
|
||||||
printf "%s\n" "source must be one of: stable, master, main" >&2
|
printf "%s\n" "source must be one of: stable, master, main" >&2
|
||||||
exit 1
|
exit 1
|
||||||
@ -314,17 +287,14 @@ parse_requirements() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# :command.initialize
|
|
||||||
initialize() {
|
initialize() {
|
||||||
version="2.0"
|
version="2.0"
|
||||||
long_usage=''
|
long_usage=''
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# src/initialize.sh
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# :command.run
|
|
||||||
run() {
|
run() {
|
||||||
declare -A args=()
|
declare -A args=()
|
||||||
declare -a other_args=()
|
declare -a other_args=()
|
||||||
|
@ -1,341 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
# This script was generated by bashly 0.8.9 (https://bashly.dannyb.co)
|
|
||||||
# Modifying it manually is not recommended
|
|
||||||
|
|
||||||
# :wrapper.bash3_bouncer
|
|
||||||
if [[ "${BASH_VERSINFO:-0}" -lt 4 ]]; then
|
|
||||||
printf "bash version 4 or higher is required\n" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# :command.master_script
|
|
||||||
# :command.root_command
|
|
||||||
root_command() {
|
|
||||||
# src/root_command.sh
|
|
||||||
# Settings
|
|
||||||
source_url=${args[source]}
|
|
||||||
publisher=${args[publisher]}
|
|
||||||
# Flags
|
|
||||||
no_call=${args[--no-call]}
|
|
||||||
dry_run=${args[--dry-run]}
|
|
||||||
|
|
||||||
REQS="wget apt-transport-https"
|
|
||||||
|
|
||||||
function do_call() {
|
|
||||||
if [[ $dry_run ]]; then
|
|
||||||
echo -e "### DRY RUN: \n$1"
|
|
||||||
else
|
|
||||||
$1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_distribution {
|
|
||||||
if [ -f /etc/os-release ]; then
|
|
||||||
. /etc/os-release
|
|
||||||
OS=$NAME
|
|
||||||
VER=$VERSION_ID
|
|
||||||
elif type lsb_release >/dev/null 2>&1; then
|
|
||||||
OS=$(lsb_release -si)
|
|
||||||
VER=$(lsb_release -sr)
|
|
||||||
elif [ -f /etc/lsb-release ]; then
|
|
||||||
. /etc/lsb-release
|
|
||||||
OS=$DISTRIB_ID
|
|
||||||
VER=$DISTRIB_RELEASE
|
|
||||||
elif [ -f /etc/debian_version ]; then
|
|
||||||
OS=Debian
|
|
||||||
VER=$(cat /etc/debian_version)
|
|
||||||
elif [ -f /etc/SuSe-release ]; then
|
|
||||||
OS=SEL
|
|
||||||
elif [ -f /etc/redhat-release ]; then
|
|
||||||
OS=RedHat
|
|
||||||
else
|
|
||||||
OS=$(uname -s)
|
|
||||||
VER=$(uname -r)
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "### Installer for InvenTree - source: $publisher/$source_url"
|
|
||||||
|
|
||||||
# Check if os and version is supported
|
|
||||||
get_distribution
|
|
||||||
echo "### Detected distribution: $OS $VER"
|
|
||||||
NOT_SUPPORTED=false
|
|
||||||
case "$OS" in
|
|
||||||
Ubuntu)
|
|
||||||
if [[ $VER != "20.04" ]]; then
|
|
||||||
NOT_SUPPORTED=true
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
Debian | Raspbian)
|
|
||||||
if [[ $VER != "11" ]]; then
|
|
||||||
NOT_SUPPORTED=true
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "### Distribution not supported"
|
|
||||||
NOT_SUPPORTED=true
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if [[ $NOT_SUPPORTED ]]; then
|
|
||||||
echo "This OS is currently not supported"
|
|
||||||
echo "please install manually using https://inventree.readthedocs.io/en/stable/start/install/"
|
|
||||||
echo "or check https://github.com/inventree/InvenTree/issues/3836 for packaging for your OS."
|
|
||||||
echo "If you think this is a bug please file an issue at"
|
|
||||||
echo "https://github.com/inventree/InvenTree/issues/new?template=install.yaml"
|
|
||||||
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "### Installing required packages for download"
|
|
||||||
for pkg in $REQS; do
|
|
||||||
if dpkg-query -W -f'${Status}' "$pkg" 2>/dev/null | grep -q "ok installed"; then
|
|
||||||
true
|
|
||||||
else
|
|
||||||
do_call "sudo apt-get -yqq install $pkg"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "### Adding key and package source"
|
|
||||||
# Add key
|
|
||||||
do_call "wget -qO- https://dl.packager.io/srv/$publisher/InvenTree/key | sudo apt-key add -"
|
|
||||||
# Add packagelist
|
|
||||||
do_call "sudo wget -O /etc/apt/sources.list.d/inventree.list https://dl.packager.io/srv/$publisher/InvenTree/$source_url/installer/${lsb_dist}/${dist_version}.repo"
|
|
||||||
|
|
||||||
echo "### Updateing package lists"
|
|
||||||
do_call "sudo apt-get update"
|
|
||||||
|
|
||||||
# Set up environment for install
|
|
||||||
echo "### Setting installer args"
|
|
||||||
if [[ $no_call ]]; then
|
|
||||||
do_call "export NO_CALL=true"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "### Installing InvenTree"
|
|
||||||
do_call "sudo apt-get install inventree -y"
|
|
||||||
|
|
||||||
echo "### Install done!"
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
# :command.version_command
|
|
||||||
version_command() {
|
|
||||||
echo "$version"
|
|
||||||
}
|
|
||||||
|
|
||||||
# :command.usage
|
|
||||||
install_usage() {
|
|
||||||
if [[ -n $long_usage ]]; then
|
|
||||||
printf "install - Interactive installer for InvenTree\n"
|
|
||||||
echo
|
|
||||||
|
|
||||||
else
|
|
||||||
printf "install - Interactive installer for InvenTree\n"
|
|
||||||
echo
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
printf "Usage:\n"
|
|
||||||
printf " install [SOURCE] [PUBLISHER] [OPTIONS]\n"
|
|
||||||
printf " install --help | -h\n"
|
|
||||||
printf " install --version | -v\n"
|
|
||||||
echo
|
|
||||||
|
|
||||||
# :command.long_usage
|
|
||||||
if [[ -n $long_usage ]]; then
|
|
||||||
printf "Options:\n"
|
|
||||||
|
|
||||||
# :command.usage_fixed_flags
|
|
||||||
echo " --help, -h"
|
|
||||||
printf " Show this help\n"
|
|
||||||
echo
|
|
||||||
echo " --version, -v"
|
|
||||||
printf " Show version number\n"
|
|
||||||
echo
|
|
||||||
|
|
||||||
# :command.usage_flags
|
|
||||||
# :flag.usage
|
|
||||||
echo " --no-call, -n"
|
|
||||||
printf " Do not call outside APIs (only functionally needed)\n"
|
|
||||||
echo
|
|
||||||
|
|
||||||
# :flag.usage
|
|
||||||
echo " --dry-run, -d"
|
|
||||||
printf " Dry run (do not install anything)\n"
|
|
||||||
echo
|
|
||||||
|
|
||||||
# :command.usage_args
|
|
||||||
printf "Arguments:\n"
|
|
||||||
|
|
||||||
# :argument.usage
|
|
||||||
echo " SOURCE"
|
|
||||||
printf " Package source that should be used\n"
|
|
||||||
printf " Allowed: stable, master, main\n"
|
|
||||||
printf " Default: stable\n"
|
|
||||||
echo
|
|
||||||
|
|
||||||
# :argument.usage
|
|
||||||
echo " PUBLISHER"
|
|
||||||
printf " Publisher that should be used\n"
|
|
||||||
printf " Default: inventree\n"
|
|
||||||
echo
|
|
||||||
|
|
||||||
# :command.usage_examples
|
|
||||||
printf "Examples:\n"
|
|
||||||
printf " install\n"
|
|
||||||
printf " install master --no-call\n"
|
|
||||||
printf " install master matmair --dry-run\n"
|
|
||||||
echo
|
|
||||||
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# :command.normalize_input
|
|
||||||
normalize_input() {
|
|
||||||
local arg flags
|
|
||||||
|
|
||||||
while [[ $# -gt 0 ]]; do
|
|
||||||
arg="$1"
|
|
||||||
if [[ $arg =~ ^(--[a-zA-Z0-9_\-]+)=(.+)$ ]]; then
|
|
||||||
input+=("${BASH_REMATCH[1]}")
|
|
||||||
input+=("${BASH_REMATCH[2]}")
|
|
||||||
elif [[ $arg =~ ^(-[a-zA-Z0-9])=(.+)$ ]]; then
|
|
||||||
input+=("${BASH_REMATCH[1]}")
|
|
||||||
input+=("${BASH_REMATCH[2]}")
|
|
||||||
elif [[ $arg =~ ^-([a-zA-Z0-9][a-zA-Z0-9]+)$ ]]; then
|
|
||||||
flags="${BASH_REMATCH[1]}"
|
|
||||||
for (( i=0 ; i < ${#flags} ; i++ )); do
|
|
||||||
input+=("-${flags:i:1}")
|
|
||||||
done
|
|
||||||
else
|
|
||||||
input+=("$arg")
|
|
||||||
fi
|
|
||||||
|
|
||||||
shift
|
|
||||||
done
|
|
||||||
}
|
|
||||||
# :command.inspect_args
|
|
||||||
inspect_args() {
|
|
||||||
readarray -t sorted_keys < <(printf '%s\n' "${!args[@]}" | sort)
|
|
||||||
if (( ${#args[@]} )); then
|
|
||||||
echo args:
|
|
||||||
for k in "${sorted_keys[@]}"; do echo "- \${args[$k]} = ${args[$k]}"; done
|
|
||||||
else
|
|
||||||
echo args: none
|
|
||||||
fi
|
|
||||||
|
|
||||||
if (( ${#other_args[@]} )); then
|
|
||||||
echo
|
|
||||||
echo other_args:
|
|
||||||
echo "- \${other_args[*]} = ${other_args[*]}"
|
|
||||||
for i in "${!other_args[@]}"; do
|
|
||||||
echo "- \${other_args[$i]} = ${other_args[$i]}"
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# :command.command_functions
|
|
||||||
|
|
||||||
# :command.parse_requirements
|
|
||||||
parse_requirements() {
|
|
||||||
# :command.fixed_flags_filter
|
|
||||||
case "${1:-}" in
|
|
||||||
--version | -v )
|
|
||||||
version_command
|
|
||||||
exit
|
|
||||||
;;
|
|
||||||
|
|
||||||
--help | -h )
|
|
||||||
long_usage=yes
|
|
||||||
install_usage
|
|
||||||
exit
|
|
||||||
;;
|
|
||||||
|
|
||||||
esac
|
|
||||||
|
|
||||||
# :command.command_filter
|
|
||||||
action="root"
|
|
||||||
|
|
||||||
# :command.parse_requirements_while
|
|
||||||
while [[ $# -gt 0 ]]; do
|
|
||||||
key="$1"
|
|
||||||
case "$key" in
|
|
||||||
# :flag.case
|
|
||||||
--no-call | -n )
|
|
||||||
|
|
||||||
# :flag.case_no_arg
|
|
||||||
args[--no-call]=1
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
|
|
||||||
# :flag.case
|
|
||||||
--dry-run | -d )
|
|
||||||
|
|
||||||
# :flag.case_no_arg
|
|
||||||
args[--dry-run]=1
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
|
|
||||||
-?* )
|
|
||||||
printf "invalid option: %s\n" "$key" >&2
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
|
|
||||||
* )
|
|
||||||
# :command.parse_requirements_case
|
|
||||||
# :command.parse_requirements_case_simple
|
|
||||||
if [[ -z ${args[source]+x} ]]; then
|
|
||||||
|
|
||||||
args[source]=$1
|
|
||||||
shift
|
|
||||||
elif [[ -z ${args[publisher]+x} ]]; then
|
|
||||||
|
|
||||||
args[publisher]=$1
|
|
||||||
shift
|
|
||||||
else
|
|
||||||
printf "invalid argument: %s\n" "$key" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
;;
|
|
||||||
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
# :command.default_assignments
|
|
||||||
[[ -n ${args[source]:-} ]] || args[source]="stable"
|
|
||||||
[[ -n ${args[publisher]:-} ]] || args[publisher]="inventree"
|
|
||||||
|
|
||||||
# :command.whitelist_filter
|
|
||||||
if [[ ! ${args[source]} =~ ^(stable|master|main)$ ]]; then
|
|
||||||
printf "%s\n" "source must be one of: stable, master, main" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
# :command.initialize
|
|
||||||
initialize() {
|
|
||||||
version="2.0"
|
|
||||||
long_usage=''
|
|
||||||
set -e
|
|
||||||
|
|
||||||
# src/initialize.sh
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
# :command.run
|
|
||||||
run() {
|
|
||||||
declare -A args=()
|
|
||||||
declare -a other_args=()
|
|
||||||
declare -a input=()
|
|
||||||
normalize_input "$@"
|
|
||||||
parse_requirements "${input[@]}"
|
|
||||||
|
|
||||||
if [[ $action == "root" ]]; then
|
|
||||||
root_command
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
initialize
|
|
||||||
run "$@"
|
|
32
contrib/installer/settings.yml
Normal file
32
contrib/installer/settings.yml
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
# All settings are optional (with their default values provided below), and
|
||||||
|
# can also be set with an environment variable with the same name, capitalized
|
||||||
|
# and prefixed by `BASHLY_` - for example: BASHLY_SOURCE_DIR
|
||||||
|
#
|
||||||
|
# When setting environment variables, you can use:
|
||||||
|
# - "0", "false" or "no" to represent false
|
||||||
|
# - "1", "true" or "yes" to represent true
|
||||||
|
|
||||||
|
# The path containing the bashly configuration and source files
|
||||||
|
source_dir: src
|
||||||
|
|
||||||
|
# The path to use for creating the bash script
|
||||||
|
target_dir: ..
|
||||||
|
|
||||||
|
# The path to use for upgrading library files, relative to the source dir
|
||||||
|
lib_dir: lib
|
||||||
|
|
||||||
|
# When true, enable bash strict mode (set -euo pipefail)
|
||||||
|
strict: false
|
||||||
|
|
||||||
|
# When true, the generated script will use tab indentation instead of spaces
|
||||||
|
# (every 2 leading spaces will be converted to a tab character)
|
||||||
|
tab_indent: false
|
||||||
|
|
||||||
|
# When true, the generated script will consider any argument in the form of
|
||||||
|
# `-abc` as if it is `-a -b -c`.
|
||||||
|
compact_short_flags: true
|
||||||
|
|
||||||
|
# Set to 'production' or 'development':
|
||||||
|
# - production generate a smaller script, without file markers
|
||||||
|
# - development generate with file markers
|
||||||
|
env: production
|
@ -1,4 +1,4 @@
|
|||||||
name: install
|
name: install.sh
|
||||||
help: Interactive installer for InvenTree
|
help: Interactive installer for InvenTree
|
||||||
version: 2.0
|
version: 2.0
|
||||||
|
|
||||||
|
@ -45,25 +45,26 @@ echo "### Installer for InvenTree - source: $publisher/$source_url"
|
|||||||
# Check if os and version is supported
|
# Check if os and version is supported
|
||||||
get_distribution
|
get_distribution
|
||||||
echo "### Detected distribution: $OS $VER"
|
echo "### Detected distribution: $OS $VER"
|
||||||
NOT_SUPPORTED=false
|
SUPPORTED=true
|
||||||
case "$OS" in
|
case "$OS" in
|
||||||
Ubuntu)
|
Ubuntu)
|
||||||
if [[ $VER != "20.04" ]]; then
|
if [[ $VER != "20.04" ]]; then
|
||||||
NOT_SUPPORTED=true
|
SUPPORTED=false
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
Debian | Raspbian)
|
"Debian GNU/Linux" | Raspbian)
|
||||||
if [[ $VER != "11" ]]; then
|
if [[ $VER != "11" ]]; then
|
||||||
NOT_SUPPORTED=true
|
SUPPORTED=false
|
||||||
fi
|
fi
|
||||||
|
OS=Debian
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "### Distribution not supported"
|
echo "### Distribution not supported"
|
||||||
NOT_SUPPORTED=true
|
SUPPORTED=false
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [[ $NOT_SUPPORTED ]]; then
|
if [[ $SUPPORTED != "true" ]]; then
|
||||||
echo "This OS is currently not supported"
|
echo "This OS is currently not supported"
|
||||||
echo "please install manually using https://inventree.readthedocs.io/en/stable/start/install/"
|
echo "please install manually using https://inventree.readthedocs.io/en/stable/start/install/"
|
||||||
echo "or check https://github.com/inventree/InvenTree/issues/3836 for packaging for your OS."
|
echo "or check https://github.com/inventree/InvenTree/issues/3836 for packaging for your OS."
|
||||||
@ -82,11 +83,10 @@ for pkg in $REQS; do
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "### Adding key and package source"
|
echo "### Getting and adding key"
|
||||||
# Add key
|
wget -qO- https://dl.packager.io/srv/$publisher/InvenTree/key | sudo apt-key add -
|
||||||
do_call "wget -qO- https://dl.packager.io/srv/$publisher/InvenTree/key | sudo apt-key add -"
|
echo "### Adding package source"
|
||||||
# Add packagelist
|
do_call "sudo wget -O /etc/apt/sources.list.d/inventree.list https://dl.packager.io/srv/$publisher/InvenTree/$source_url/installer/${OS,,}/${VER}.repo"
|
||||||
do_call "sudo wget -O /etc/apt/sources.list.d/inventree.list https://dl.packager.io/srv/$publisher/InvenTree/$source_url/installer/${lsb_dist}/${dist_version}.repo"
|
|
||||||
|
|
||||||
echo "### Updateing package lists"
|
echo "### Updateing package lists"
|
||||||
do_call "sudo apt-get update"
|
do_call "sudo apt-get update"
|
||||||
|
@ -84,7 +84,7 @@ function detect_envs() {
|
|||||||
|
|
||||||
echo "# Setting base environment variables"
|
echo "# Setting base environment variables"
|
||||||
|
|
||||||
export INVENTREE_CONFIG_FILE=${CONF_DIR}/config.yaml
|
export INVENTREE_CONFIG_FILE=${INVENTREE_CONFIG_FILE:-${CONF_DIR}/config.yaml}
|
||||||
|
|
||||||
if test -f "${INVENTREE_CONFIG_FILE}"; then
|
if test -f "${INVENTREE_CONFIG_FILE}"; then
|
||||||
echo "# Using existing config file: ${INVENTREE_CONFIG_FILE}"
|
echo "# Using existing config file: ${INVENTREE_CONFIG_FILE}"
|
||||||
@ -93,22 +93,22 @@ function detect_envs() {
|
|||||||
pip install jc -q
|
pip install jc -q
|
||||||
|
|
||||||
# Load config
|
# Load config
|
||||||
local conf=$(cat ${INVENTREE_CONFIG_FILE} | jc --yaml)
|
local CONF=$(cat ${INVENTREE_CONFIG_FILE} | jc --yaml)
|
||||||
|
|
||||||
# Parse the config file
|
# Parse the config file
|
||||||
export INVENTREE_MEDIA_ROOT=$conf | jq '.[].media_root'
|
export INVENTREE_MEDIA_ROOT=$(jq -r '.[].media_root' <<< ${CONF})
|
||||||
export INVENTREE_STATIC_ROOT=$conf | jq '.[].static_root'
|
export INVENTREE_STATIC_ROOT=$(jq -r '.[].static_root' <<< ${CONF})
|
||||||
export INVENTREE_BACKUP_DIR=$conf | jq '.[].backup_dir'
|
export INVENTREE_BACKUP_DIR=$(jq -r '.[].backup_dir' <<< ${CONF})
|
||||||
export INVENTREE_PLUGINS_ENABLED=$conf | jq '.[].plugins_enabled'
|
export INVENTREE_PLUGINS_ENABLED=$(jq -r '.[].plugins_enabled' <<< ${CONF})
|
||||||
export INVENTREE_PLUGIN_FILE=$conf | jq '.[].plugin_file'
|
export INVENTREE_PLUGIN_FILE=$(jq -r '.[].plugin_file' <<< ${CONF})
|
||||||
export INVENTREE_SECRET_KEY_FILE=$conf | jq '.[].secret_key_file'
|
export INVENTREE_SECRET_KEY_FILE=$(jq -r '.[].secret_key_file' <<< ${CONF})
|
||||||
|
|
||||||
export INVENTREE_DB_ENGINE=$conf | jq '.[].database.ENGINE'
|
export INVENTREE_DB_ENGINE=$(jq -r '.[].database.ENGINE' <<< ${CONF})
|
||||||
export INVENTREE_DB_NAME=$conf | jq '.[].database.NAME'
|
export INVENTREE_DB_NAME=$(jq -r '.[].database.NAME' <<< ${CONF})
|
||||||
export INVENTREE_DB_USER=$conf | jq '.[].database.USER'
|
export INVENTREE_DB_USER=$(jq -r '.[].database.USER' <<< ${CONF})
|
||||||
export INVENTREE_DB_PASSWORD=$conf | jq '.[].database.PASSWORD'
|
export INVENTREE_DB_PASSWORD=$(jq -r '.[].database.PASSWORD' <<< ${CONF})
|
||||||
export INVENTREE_DB_HOST=$conf | jq '.[].database.HOST'
|
export INVENTREE_DB_HOST=$(jq -r '.[].database.HOST' <<< ${CONF})
|
||||||
export INVENTREE_DB_PORT=$conf | jq '.[].database.PORT'
|
export INVENTREE_DB_PORT=$(jq -r '.[].database.PORT' <<< ${CONF})
|
||||||
else
|
else
|
||||||
echo "# No config file found: ${INVENTREE_CONFIG_FILE}, using envs or defaults"
|
echo "# No config file found: ${INVENTREE_CONFIG_FILE}, using envs or defaults"
|
||||||
|
|
||||||
@ -160,7 +160,8 @@ function create_initscripts() {
|
|||||||
echo "# python enviroment already present - skipping"
|
echo "# python enviroment already present - skipping"
|
||||||
else
|
else
|
||||||
echo "# Setting up python enviroment"
|
echo "# Setting up python enviroment"
|
||||||
sudo -u ${APP_USER} --preserve-env=$SETUP_ENVS bash -c "cd ${APP_HOME} && python3 -m venv env && pip install invoke"
|
sudo -u ${APP_USER} --preserve-env=$SETUP_ENVS bash -c "cd ${APP_HOME} && ${SETUP_PYTHON} -m venv env"
|
||||||
|
sudo -u ${APP_USER} --preserve-env=$SETUP_ENVS bash -c "cd ${APP_HOME} && env/bin/pip install invoke wheel"
|
||||||
|
|
||||||
if [ -n "${SETUP_EXTRA_PIP}" ]; then
|
if [ -n "${SETUP_EXTRA_PIP}" ]; then
|
||||||
echo "# Installing extra pip packages"
|
echo "# Installing extra pip packages"
|
||||||
|
@ -11,7 +11,7 @@ PATH=${APP_HOME}/env/bin:${APP_HOME}/:/sbin:/bin:/usr/sbin:/usr/bin:
|
|||||||
. ${APP_HOME}/contrib/packager.io/functions.sh
|
. ${APP_HOME}/contrib/packager.io/functions.sh
|
||||||
|
|
||||||
# Envs that should be passed to setup commands
|
# Envs that should be passed to setup commands
|
||||||
export SETUP_ENVS=PATH,APP_HOME,INVENTREE_MEDIA_ROOT,INVENTREE_STATIC_ROOT,INVENTREE_PLUGINS_ENABLED,INVENTREE_PLUGIN_FILE,INVENTREE_CONFIG_FILE,INVENTREE_SECRET_KEY_FILE,INVENTREE_DB_ENGINE,INVENTREE_DB_NAME,INVENTREE_DB_USER,INVENTREE_DB_PASSWORD,INVENTREE_DB_HOST,INVENTREE_DB_PORT,INVENTREE_ADMIN_USER,INVENTREE_ADMIN_EMAIL,INVENTREE_ADMIN_PASSWORD,SETUP_NGINX_FILE,SETUP_ADMIN_PASSWORD_FILE,SETUP_NO_CALLS,SETUP_DEBUG,SETUP_EXTRA_PIP
|
export SETUP_ENVS=PATH,APP_HOME,INVENTREE_MEDIA_ROOT,INVENTREE_STATIC_ROOT,INVENTREE_BACKUP_DIR,INVENTREE_PLUGINS_ENABLED,INVENTREE_PLUGIN_FILE,INVENTREE_CONFIG_FILE,INVENTREE_SECRET_KEY_FILE,INVENTREE_DB_ENGINE,INVENTREE_DB_NAME,INVENTREE_DB_USER,INVENTREE_DB_PASSWORD,INVENTREE_DB_HOST,INVENTREE_DB_PORT,INVENTREE_ADMIN_USER,INVENTREE_ADMIN_EMAIL,INVENTREE_ADMIN_PASSWORD,SETUP_NGINX_FILE,SETUP_ADMIN_PASSWORD_FILE,SETUP_NO_CALLS,SETUP_DEBUG,SETUP_EXTRA_PIP,SETUP_PYTHON
|
||||||
|
|
||||||
# Get the envs
|
# Get the envs
|
||||||
detect_local_env
|
detect_local_env
|
||||||
@ -23,8 +23,10 @@ export DATA_DIR=${APP_HOME}/data
|
|||||||
export SETUP_NGINX_FILE=${SETUP_NGINX_FILE:-/etc/nginx/sites-enabled/inventree.conf}
|
export SETUP_NGINX_FILE=${SETUP_NGINX_FILE:-/etc/nginx/sites-enabled/inventree.conf}
|
||||||
export SETUP_ADMIN_PASSWORD_FILE=${CONF_DIR}/admin_password.txt
|
export SETUP_ADMIN_PASSWORD_FILE=${CONF_DIR}/admin_password.txt
|
||||||
export SETUP_NO_CALLS=${SETUP_NO_CALLS:-false}
|
export SETUP_NO_CALLS=${SETUP_NO_CALLS:-false}
|
||||||
|
export SETUP_PYTHON=${SETUP_PYTHON:-python3}
|
||||||
# SETUP_DEBUG can be set to get debug info
|
# SETUP_DEBUG can be set to get debug info
|
||||||
# SETUP_EXTRA_PIP can be set to install extra pip packages
|
# SETUP_EXTRA_PIP can be set to install extra pip packages
|
||||||
|
# SETUP_PYTHON can be set to use a different python version
|
||||||
|
|
||||||
# get base info
|
# get base info
|
||||||
detect_envs
|
detect_envs
|
||||||
|
Loading…
x
Reference in New Issue
Block a user