scripts: consolidate Agent deployment and remove Probe packages
Use Agent for native, container, systemd and OpenWrt installations and signed updates. Remove retired Probe deployment templates and smoke scripts.
This commit is contained in:
1 parent
ad5efc62ff
commit
016dbc2bbf
30 files changed
+96
-1206
No files matched your search
+12
-17
@@ -1,10 +1,9 @@
|
||||
#!/bin/sh
|
||||
# Installs moshiro-agent or moshiro-probe from an extracted release directory (the directory this script lives in).
|
||||
# Installs moshiro-agent or moshiro-agent from an extracted release directory (the directory this script lives in).
|
||||
# POSIX sh: runs on Debian/Ubuntu/Alpine/OpenWrt (busybox).
|
||||
#
|
||||
# ./install.sh agent --server https://panel.example.com --join <join-token> --name hk-1
|
||||
# ./install.sh probe --server https://panel --join jt_xxx --name home-1
|
||||
# ./install.sh uninstall agent|probe [--purge]
|
||||
# ./install.sh uninstall agent [--purge]
|
||||
#
|
||||
# Binaries go to /usr/lib/moshiro (root-owned: the collector cannot rewrite its own executable);
|
||||
# config and identity go to /etc/moshiro (owned by the unprivileged `moshiro` user).
|
||||
@@ -80,7 +79,7 @@ write_config() {
|
||||
}
|
||||
JSON
|
||||
else
|
||||
cat >"$CONFIG/probe.json" <<JSON
|
||||
cat >"$CONFIG/agent.json" <<JSON
|
||||
{
|
||||
"fleet": { "server": "$2", "identity_dir": "$CONFIG" }
|
||||
}
|
||||
@@ -122,8 +121,7 @@ install_role() {
|
||||
if [ "$have_user" -eq 0 ]; then sed -i '/^User=/d;/^Group=/d' "/etc/systemd/system/moshiro-$role.service"; fi
|
||||
systemctl daemon-reload ;;
|
||||
procd)
|
||||
[ "$role" = probe ] || die "the agent is meant for servers; on OpenWrt only the probe is supported"
|
||||
put 0755 "$HERE/openwrt/moshiro-probe.init" /etc/init.d/moshiro-probe
|
||||
put 0755 "$HERE/openwrt/moshiro-agent.init" /etc/init.d/moshiro-agent
|
||||
mkdir -p /lib/upgrade/keep.d
|
||||
put 0644 "$HERE/openwrt/moshiro.keep" /lib/upgrade/keep.d/moshiro ;;
|
||||
*) echo "warning: no systemd or procd found: start with LD_LIBRARY_PATH=$PREFIX $PREFIX/moshiro-$role --config $CONFIG/$role.json under your own supervisor" >&2 ;;
|
||||
@@ -145,14 +143,14 @@ install_role() {
|
||||
if [ "$ready" -eq 1 ] && [ "$no_start" -eq 0 ]; then
|
||||
case "$init" in
|
||||
systemd) systemctl enable --now "moshiro-$role" ;;
|
||||
procd) /etc/init.d/moshiro-probe enable; /etc/init.d/moshiro-probe restart ;;
|
||||
procd) /etc/init.d/moshiro-agent enable; /etc/init.d/moshiro-agent restart ;;
|
||||
esac
|
||||
say "moshiro-$role is installed"
|
||||
else
|
||||
say "installed, not started yet. Next:"
|
||||
echo " $PREFIX/fleet-enroll --server <panel-url> --join <token> --name <name> --identity-dir $CONFIG (as the '$USER_NAME' user)"
|
||||
echo " write $CONFIG/$role.json (see README.md), then: systemctl enable --now moshiro-$role"
|
||||
[ "$role" = agent ] || echo " (OpenWrt: /etc/init.d/moshiro-probe enable && /etc/init.d/moshiro-probe start)"
|
||||
echo " (OpenWrt: /etc/init.d/moshiro-agent enable && /etc/init.d/moshiro-agent start)"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -165,15 +163,13 @@ uninstall() {
|
||||
rm -f "/etc/systemd/system/moshiro-$role.service"
|
||||
systemctl daemon-reload ;;
|
||||
procd)
|
||||
/etc/init.d/moshiro-probe stop 2>/dev/null || true
|
||||
/etc/init.d/moshiro-probe disable 2>/dev/null || true
|
||||
rm -f /etc/init.d/moshiro-probe /lib/upgrade/keep.d/moshiro ;;
|
||||
/etc/init.d/moshiro-agent stop 2>/dev/null || true
|
||||
/etc/init.d/moshiro-agent disable 2>/dev/null || true
|
||||
rm -f /etc/init.d/moshiro-agent /lib/upgrade/keep.d/moshiro ;;
|
||||
esac
|
||||
rm -f "$PREFIX/moshiro-$role"
|
||||
rm -f "$PREFIX/fleet-enroll"
|
||||
other_role=agent
|
||||
[ "$role" = agent ] && other_role=probe
|
||||
[ -x "$PREFIX/moshiro-$other_role" ] || rm -f "$PREFIX"/lib*.so.*
|
||||
rm -f "$PREFIX"/lib*.so.*
|
||||
rmdir "$PREFIX" 2>/dev/null || true
|
||||
if [ "$purge" -eq 1 ]; then
|
||||
rm -rf "$CONFIG"
|
||||
@@ -185,12 +181,11 @@ uninstall() {
|
||||
|
||||
cmd="${1:-}"
|
||||
case "$cmd" in
|
||||
agent|probe) shift; install_role "$cmd" "$@" ;;
|
||||
agent) shift; install_role "$cmd" "$@" ;;
|
||||
uninstall)
|
||||
shift
|
||||
role="${1:-}"
|
||||
[ "$role" = agent ] || [ "$role" = probe ] || die "usage: install.sh uninstall agent|probe [--purge]"
|
||||
shift
|
||||
uninstall "$role" "$@" ;;
|
||||
*) die "usage: install.sh agent|probe [options] | uninstall agent|probe [--purge]" ;;
|
||||
*) die "usage: install.sh agent [options] | uninstall agent [--purge]" ;;
|
||||
esac
|
||||
Reference in new issue
Block a user