refactor!: rename the project from Monitor to MoShiro [CI]
ci/woodpecker/push/main-amd64-build Pipeline was successful
ci/woodpecker/push/main-amd64-build Pipeline was successful
Namespaces, assemblies, solution, binaries, images, systemd units, config paths, environment variables, protocol methods and the Linux user are all renamed. Breaking: existing databases, node identities and installed units must be recreated.
This commit is contained in:
1 parent
27ac7fb787
commit
2e146d4da7
309 files changed
+1565
-1572
No files matched your search
+23
-23
@@ -1,18 +1,18 @@
|
||||
#!/bin/sh
|
||||
# Installs monitor-agent or monitor-probe from an extracted release directory (the directory this script lives in).
|
||||
# Installs moshiro-agent or moshiro-probe 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 [--probe-json /path/to/probe.json]
|
||||
# ./install.sh uninstall agent|probe [--purge]
|
||||
#
|
||||
# Binaries go to /usr/lib/monitor (root-owned: the collector cannot rewrite its own executable);
|
||||
# config and identity go to /etc/monitor (owned by the unprivileged `monitor` user).
|
||||
# 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).
|
||||
set -eu
|
||||
|
||||
PREFIX=/usr/lib/monitor
|
||||
CONFIG=/etc/monitor
|
||||
USER_NAME=monitor
|
||||
PREFIX=/usr/lib/moshiro
|
||||
CONFIG=/etc/moshiro
|
||||
USER_NAME=moshiro
|
||||
HERE="$(cd "$(dirname "$0")" && pwd)"
|
||||
|
||||
# busybox on OpenWrt has no `install`
|
||||
@@ -95,22 +95,22 @@ install_role() {
|
||||
if [ "$have_user" -eq 1 ]; then chown "$USER_NAME" "$CONFIG"; fi
|
||||
chmod 0750 "$CONFIG"
|
||||
|
||||
install_binary "monitor-$role"
|
||||
install_binary "moshiro-$role"
|
||||
if [ "$role" = agent ]; then install_binary fleet-enroll; fi
|
||||
say "installed binaries to $PREFIX"
|
||||
|
||||
init="$(init_system)"
|
||||
case "$init" in
|
||||
systemd)
|
||||
put 0644 "$HERE/systemd/monitor-$role.service" "/etc/systemd/system/monitor-$role.service"
|
||||
if [ "$have_user" -eq 0 ]; then sed -i '/^User=/d;/^Group=/d' "/etc/systemd/system/monitor-$role.service"; fi
|
||||
put 0644 "$HERE/systemd/moshiro-$role.service" "/etc/systemd/system/moshiro-$role.service"
|
||||
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/monitor-probe.init" /etc/init.d/monitor-probe
|
||||
put 0755 "$HERE/openwrt/moshiro-probe.init" /etc/init.d/moshiro-probe
|
||||
mkdir -p /lib/upgrade/keep.d
|
||||
put 0644 "$HERE/openwrt/monitor.keep" /lib/upgrade/keep.d/monitor ;;
|
||||
*) echo "warning: no systemd or procd found: start $PREFIX/monitor-$role --config $CONFIG/$role.json with your own supervisor" >&2 ;;
|
||||
put 0644 "$HERE/openwrt/moshiro.keep" /lib/upgrade/keep.d/moshiro ;;
|
||||
*) echo "warning: no systemd or procd found: start $PREFIX/moshiro-$role --config $CONFIG/$role.json with your own supervisor" >&2 ;;
|
||||
esac
|
||||
|
||||
ready=0
|
||||
@@ -136,18 +136,18 @@ install_role() {
|
||||
|
||||
if [ "$ready" -eq 1 ] && [ "$no_start" -eq 0 ]; then
|
||||
case "$init" in
|
||||
systemd) systemctl enable --now "monitor-$role" ;;
|
||||
procd) /etc/init.d/monitor-probe enable; /etc/init.d/monitor-probe restart ;;
|
||||
systemd) systemctl enable --now "moshiro-$role" ;;
|
||||
procd) /etc/init.d/moshiro-probe enable; /etc/init.d/moshiro-probe restart ;;
|
||||
esac
|
||||
say "monitor-$role is installed"
|
||||
say "moshiro-$role is installed"
|
||||
else
|
||||
say "installed, not started yet. Next:"
|
||||
if [ "$role" = agent ]; then
|
||||
echo " $PREFIX/fleet-enroll --server <panel-url> --join <token> --name <name> --identity-dir $CONFIG (as the '$USER_NAME' user)"
|
||||
echo " write $CONFIG/agent.json (see README.md), then: systemctl enable --now monitor-agent"
|
||||
echo " write $CONFIG/agent.json (see README.md), then: systemctl enable --now moshiro-agent"
|
||||
else
|
||||
echo " save the panel's probe identity (POST /api/admin/probe/identity) as $CONFIG/probe.json (mode 0600, owner $USER_NAME)"
|
||||
echo " then: systemctl enable --now monitor-probe (OpenWrt: /etc/init.d/monitor-probe enable && /etc/init.d/monitor-probe start)"
|
||||
echo " then: systemctl enable --now moshiro-probe (OpenWrt: /etc/init.d/moshiro-probe enable && /etc/init.d/moshiro-probe start)"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
@@ -157,15 +157,15 @@ uninstall() {
|
||||
if [ "${2:-}" = "--purge" ]; then purge=1; fi
|
||||
case "$(init_system)" in
|
||||
systemd)
|
||||
systemctl disable --now "monitor-$role" 2>/dev/null || true
|
||||
rm -f "/etc/systemd/system/monitor-$role.service"
|
||||
systemctl disable --now "moshiro-$role" 2>/dev/null || true
|
||||
rm -f "/etc/systemd/system/moshiro-$role.service"
|
||||
systemctl daemon-reload ;;
|
||||
procd)
|
||||
/etc/init.d/monitor-probe stop 2>/dev/null || true
|
||||
/etc/init.d/monitor-probe disable 2>/dev/null || true
|
||||
rm -f /etc/init.d/monitor-probe /lib/upgrade/keep.d/monitor ;;
|
||||
/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 ;;
|
||||
esac
|
||||
rm -f "$PREFIX/monitor-$role"
|
||||
rm -f "$PREFIX/moshiro-$role"
|
||||
if [ "$role" = agent ]; then rm -f "$PREFIX/fleet-enroll"; fi
|
||||
rmdir "$PREFIX" 2>/dev/null || true
|
||||
if [ "$purge" -eq 1 ]; then
|
||||
|
||||
Reference in new issue
Block a user