AnyBot/deploy/linux/hands.sh

39 lines
1.9 KiB
Bash
Raw Normal View History

#!/bin/sh
# Make this Linux computer a pair of hands for your AnyBot brain (or a brain itself): installs what
# it needs, then opens the guided setup (`anybot setup`), where you pick the brain from your
# account's AnyBots. Works on a desktop and on a computer without a screen. Run from app/:
#
# ./deploy/linux/hands.sh --deps also install what a computer without a screen needs (sudo)
# ./deploy/linux/hands.sh install AnyBot if needed, then the setup
# ./deploy/linux/hands.sh --stop stop AnyBot and don't start it with the computer any more
set -e
cd "$(dirname "$0")/../.."
if [ "$1" = "--stop" ]; then
for u in anybot.service anybot-hands.service; do
systemctl --user disable --now "$u" 2>/dev/null || true
rm -f "$HOME/.config/systemd/user/$u"
done
systemctl --user daemon-reload 2>/dev/null || true
echo "Stopped. Run ./deploy/linux/hands.sh (or anybot setup) to set it up again."
exit 0
fi
if [ "$1" = "--deps" ]; then
# A virtual screen, a window manager, the accessibility bus (for reading apps' buttons), a session bus.
if command -v apt-get >/dev/null; then
sudo apt-get update && sudo apt-get install -y xvfb openbox at-spi2-core libatk-adaptor dbus-x11 dbus-user-session xauth fonts-noto-cjk
elif command -v dnf >/dev/null; then
sudo dnf install -y xorg-x11-server-Xvfb openbox at-spi2-core at-spi2-atk dbus-x11 xorg-x11-xauth google-noto-sans-cjk-fonts
elif command -v pacman >/dev/null; then
sudo pacman -S --needed xorg-server-xvfb openbox at-spi2-core dbus xorg-xauth noto-fonts-cjk
else
echo "Install with your package manager: Xvfb, openbox, at-spi2-core, dbus, xauth"
fi
fi
[ -x "$HOME/.local/bin/anybot" ] || sh deploy/linux/install.sh
# Older versions of this script kept the account in a file; the setup keeps only a key.
rm -f "$HOME/.config/anybot/hands.env" "$HOME/.local/bin/anybot-hands"
exec "$HOME/.local/bin/anybot" setup