Skip to content

Commit

Permalink
homebridge raspberry pi image override
Browse files Browse the repository at this point in the history
  • Loading branch information
oznu committed Apr 28, 2022
1 parent 995158a commit d33db30
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions deb/debian/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,27 @@ if [ "$1" = "configure" ]; then
# fix permissions on homebridge user home
chown -R homebridge: /home/homebridge/.bashrc

# source /etc/os-release to get OS ID
. /etc/os-release

# add user to default groups if running on raspbian
if [ "$ID" = "raspbian" ]; then
for groupName in udio bluetooth dialout gpio video input i2c spi audio render; do
usermod -a -G $groupName homebridge 2> /dev/null
done
fi

# if running on Offical Homebridge Raspberry Pi, run as the "pi" user instead
if [ -z $2 ] && [ "$ID" = "raspbian" ] && [ -f /etc/hb-release ] && [ ! -f /etc/systemd/system/homebridge.service.d/override.conf ]; then
getent passwd pi > /dev/null
if [ "$?" -eq 0 ]; then
mkdir -p /etc/systemd/system/homebridge.service.d
echo "[Service]" > /etc/systemd/system/homebridge.service.d/override.conf
echo "User=pi" >> /etc/systemd/system/homebridge.service.d/override.conf
echo "Environment=\"UIX_CAN_SHUTDOWN_RESTART_HOST=1\"" >> /etc/systemd/system/homebridge.service.d/override.conf
fi
fi

# clear any masks on the homebridge service
systemctl unmask homebridge.service 2> /dev/null

Expand All @@ -64,14 +85,6 @@ if [ "$1" = "configure" ]; then

# create symlink to hb-shell
ln -fs /opt/homebridge/hb-shell /usr/local/bin/hb-shell

# add user to default groups if running on raspbian
. /etc/os-release
if [ "$ID" = "raspbian" ]; then
for groupName in udio bluetooth dialout gpio video input i2c spi audio render; do
usermod -a -G $groupName homebridge 2> /dev/null
done
fi
fi

# post-install only
Expand Down

0 comments on commit d33db30

Please sign in to comment.