aboutsummaryrefslogtreecommitdiffstats
path: root/install.sh
diff options
context:
space:
mode:
Diffstat (limited to 'install.sh')
-rwxr-xr-xinstall.sh45
1 files changed, 45 insertions, 0 deletions
diff --git a/install.sh b/install.sh
new file mode 100755
index 0000000..464bde9
--- /dev/null
+++ b/install.sh
@@ -0,0 +1,45 @@
+#!/bin/bash
+# sb-builder - install the GUI locally, or the helper on the VM
+# Copyright (C) 2026 Danilo M. <danix@danix.xyz>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+# ./install.sh symlink the launcher into ~/bin (BINDIR overrides),
+# create the GUI config from the example if missing
+# ./install.sh --remote deploy remote/sbb-remote to the VM (SBB_TARGET,
+# default buildsystem) and create its config if missing
+
+set -euo pipefail
+here=$(dirname "$(readlink -f "$0")")
+
+if [[ ${1:-} == --remote ]]; then
+ target=${SBB_TARGET:-buildsystem}
+ read -rp "Deploy sbb-remote to $target:/usr/local/bin (config created only if missing)? [y/N] " a
+ [[ $a =~ ^[Yy]$ ]] || exit 1
+ scp -q "$here/remote/sbb-remote" "$target:/usr/local/bin/sbb-remote"
+ scp -q "$here/remote/config.example.toml" "$target:/tmp/sbb-config.example.toml"
+ ssh "$target" 'chmod 755 /usr/local/bin/sbb-remote &&
+ mkdir -p /etc/sb-builder &&
+ { [ -e /etc/sb-builder/config.toml ] || cp /tmp/sbb-config.example.toml /etc/sb-builder/config.toml; } &&
+ rm -f /tmp/sbb-config.example.toml &&
+ sbb-remote version'
+ exit
+fi
+
+bindir=${BINDIR:-$HOME/bin}
+cfgdir=${XDG_CONFIG_HOME:-$HOME/.config}/sb-builder
+mkdir -p "$bindir" "$cfgdir"
+ln -sfn "$here/sb-builder" "$bindir/sb-builder"
+[[ -e $cfgdir/config.toml ]] || cp "$here/config.example.toml" "$cfgdir/config.toml"
+echo "installed $bindir/sb-builder -> $here/sb-builder, config in $cfgdir/config.toml"