fix: install script should not copy over itself

This commit is contained in:
Andreas Wrede
2026-05-01 12:48:29 -04:00
parent 6aae2a1dab
commit a77f6d380c
+13 -5
View File
@@ -14,12 +14,13 @@ what=$1
on_ha=0 on_ha=0
where="" where=""
venv="" venv=""
prog=$(realpath $0)
[ "$2" = "HA" ] && on_ha=1 [ "$2" = "HA" ] && on_ha=1
[ -z "$what" ] && what="client" [ -z "$what" ] && what="client"
if [ -d /homeassistant ]; then if [ -d /homeassistant ]; then
echo "HA, running \"docker exec homeassistant $0 $@\"" echo "HA, running \"docker exec homeassistant $prog $@\""
docker exec homeassistant $0 $@ HA docker exec homeassistant $prog $@ HA
rc=$? rc=$?
if [ $rc -ne 0 ]; then if [ $rc -ne 0 ]; then
echo "Failed to install heartbeat in HA, please check the logs for more details" echo "Failed to install heartbeat in HA, please check the logs for more details"
@@ -88,7 +89,14 @@ else
echo "Installing heartbeat $what in virtual environment $venv/hbd" echo "Installing heartbeat $what in virtual environment $venv/hbd"
. $venv/hbd/bin/activate . $venv/hbd/bin/activate
fi fi
if [ "$what" = "mini" ]; then
echo "Installing hbc mini, which has no external dependencies and is meant for quick setup and testing. For the full client with all features, please run this script with the 'client' argument."
curl -s -o $where/hbc_mini https://git.wrede.ca/andreas/heartbeat/raw/branch/master/scripts/hbc_mini.py
chmod +x $where/hbc_mini
else
echo "Installing heartbeat $what, which includes the full client with all features. If you want to install the minimal client with no external dependencies, please run this script with the 'mini' argument."
python3 -mpip install --upgrade --index-url https://git.wrede.ca/api/packages/andreas/pypi/simple/ --extra-index-url https://pypi.org/simple hbd[$what] python3 -mpip install --upgrade --index-url https://git.wrede.ca/api/packages/andreas/pypi/simple/ --extra-index-url https://pypi.org/simple hbd[$what]
fi
if [ "$what" = "server" ]; then if [ "$what" = "server" ]; then
rm -f $where/hbd rm -f $where/hbd
@@ -104,8 +112,8 @@ elif [ "$what" = "client" ]; then
rm -f $where/hbc rm -f $where/hbc
ln -sf $(which hbc) $where/hbc ln -sf $(which hbc) $where/hbc
fi fi
if [ "$0" != "$where/hb_install.sh" ]; then if [ "$prog" != "$where/hb_install.sh" ]; then
cp "$0" $where/hb_install.sh cp "$prog" $where/hb_install.sh
chmod +x $where/hb_install.sh chmod +x $where/hb_install.sh
fi fi
if [ $on_ha -eq 1 ]; then if [ $on_ha -eq 1 ]; then
@@ -118,7 +126,7 @@ elif [ "$what" = "client" ]; then
elif [ "$what" = "mini" ]; then elif [ "$what" = "mini" ]; then
hbc_path=$(which hbc_mini) hbc_path=$(which hbc_mini)
if [ "$hbc_path" != "$where/hbc_mini" ]; then if [ "$hbc_path" != "$where/hbc_mini" ]; then
ln -sf $(which hbc) $where/hbc_mini ln -sf $hbc_path $where/hbc_mini
fi fi
echo "hbc mini installed, you can run it with \"$where/hbc_mini\" or \"hbc_mini\" if $where is in your PATH" echo "hbc mini installed, you can run it with \"$where/hbc_mini\" or \"hbc_mini\" if $where is in your PATH"
fi fi