forked from ungleich-public/cdist-contrib
__netbox: don't call pip3 uninstall
if nothing available
To avoid an error from pip, it will be checked if there are packages to uninstall. This is better than just doing `|| true`.
This commit is contained in:
parent
13e97d171b
commit
32c95ccb22
1 changed files with 8 additions and 3 deletions
|
@ -66,12 +66,16 @@ ln -fs /opt/netbox/cdist/ldap_config.py '$install_dir/netbox/ldap_config.py'
|
||||||
virtualenv -p python3 /opt/netbox/venv
|
virtualenv -p python3 /opt/netbox/venv
|
||||||
|
|
||||||
# Uninstall packages not required anymore
|
# Uninstall packages not required anymore
|
||||||
# if versions not shortend, they will be ignored by pip, but not by comm
|
# if versions not be shortend, they will be ignored by pip, but not by comm
|
||||||
# all of this could be done with grep, too, but it's still must be shortend with awk
|
# all of this could be done with grep, too, but it's still must be shortend with awk
|
||||||
awk -F== '{print $1}' '/opt/netbox/requirements.txt' | sort > "\$tmpdir/curr-reqs.txt"
|
awk -F== '{print $1}' '/opt/netbox/requirements.txt' | sort > "\$tmpdir/curr-reqs.txt"
|
||||||
awk -F== '{print $1}' '/opt/netbox/old-requirements.txt' | sort > "\$tmpdir/old-reqs.txt"
|
awk -F== '{print $1}' '/opt/netbox/old-requirements.txt' | sort > "\$tmpdir/old-reqs.txt"
|
||||||
comm -23 "\$tmpdir/old-reqs.txt" "\$tmpdir/curr-reqs.txt" \
|
comm -23 "\$tmpdir/old-reqs.txt" "\$tmpdir/curr-reqs.txt" > "\$tmpdir/pip-uninstall.txt"
|
||||||
| xargs /opt/netbox/venv/bin/pip3 uninstall -qy
|
|
||||||
|
# only uninstall if something is available (to avoid errors cause of this)
|
||||||
|
if [ -s "\$tmpdir/pip-uninstall.txt" ]; then
|
||||||
|
/opt/netbox/venv/bin/pip3 uninstall -qy -r "\$tmpdir/pip-uninstall.txt"
|
||||||
|
fi
|
||||||
|
|
||||||
# Install python dependencies.
|
# Install python dependencies.
|
||||||
# avoid gunicorn, because it will be done in an other type
|
# avoid gunicorn, because it will be done in an other type
|
||||||
|
@ -86,6 +90,7 @@ EOF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cat << EOF
|
cat << EOF
|
||||||
|
|
||||||
# Set final permissions.
|
# Set final permissions.
|
||||||
chown -R netbox /opt/netbox
|
chown -R netbox /opt/netbox
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue