2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-14 19:15:41 +00:00

Installer v2 (#3798)

* add initial advanced installer

* add symlink

* add dist detection

* make output uniform

* switch command to use wget
leave the installer on device

* regen script

* only install if not already there

* add os/version check
Closes #3835

* regenerate script

* fix case syntax

* fix typo

* rename assets to replace installer

* Add issue template for install problems

* Add link to open issue

* Update linked file
This commit is contained in:
Matthias Mair
2022-11-08 00:12:43 +01:00
committed by GitHub
parent 92260f2059
commit adcb975853
8 changed files with 871 additions and 50 deletions

View File

@ -0,0 +1,28 @@
name: install
help: Interactive installer for InvenTree
version: 2.0
args:
- name: source
help: Package source that should be used
default: stable
allowed:
- stable
- master
- main
- name: publisher
help: Publisher that should be used
default: inventree
flags:
- long: --no-call
short: -n
help: Do not call outside APIs (only functionally needed)
- long: --dry-run
short: -d
help: Dry run (do not install anything)
examples:
- install
- install master --no-call
- install master matmair --dry-run

View File

@ -0,0 +1,6 @@
## Code here runs inside the initialize() function
## Use it for anything that you need to run before any other function, like
## setting environment variables:
## CONFIG_FILE=settings.ini
##
## Feel free to empty (but not delete) this file.

View File

@ -0,0 +1,103 @@
# 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!"