feat: initial commit
This commit is contained in:
15
misc/packaging/common/config-agent.yml
Normal file
15
misc/packaging/common/config-agent.yml
Normal file
@ -0,0 +1,15 @@
|
||||
agent:
|
||||
reconciliationInterval: 5
|
||||
controllers:
|
||||
persistence:
|
||||
enabled: true
|
||||
stateFile: /var/lib/emissary/state.json
|
||||
spec:
|
||||
enabled: true
|
||||
serverUrl: http://192.168.0.45:3000
|
||||
gateway:
|
||||
enabled: true
|
||||
uci:
|
||||
enabled: true
|
||||
binPath: uci
|
||||
configBackupFile: /var/lib/emissary/uci-backup.conf
|
24
misc/packaging/common/config-server.yml
Normal file
24
misc/packaging/common/config-server.yml
Normal file
@ -0,0 +1,24 @@
|
||||
http:
|
||||
host: 0.0.0.0
|
||||
port: 3000
|
||||
logger:
|
||||
level: 1
|
||||
format: human
|
||||
database:
|
||||
driver: sqlite
|
||||
dsn: sqlite:///var/lib/emissary/data.sqlite
|
||||
cors:
|
||||
allowedOrigins: []
|
||||
allowCredentials: true
|
||||
allowMethods:
|
||||
- POST
|
||||
- GET
|
||||
- PUT
|
||||
- DELETE
|
||||
allowedHeaders:
|
||||
- Origin
|
||||
- Accept
|
||||
- Content-Type
|
||||
- Authorization
|
||||
- Sentry-Trace
|
||||
debug: false
|
73
misc/packaging/common/postinstall-agent.sh
Normal file
73
misc/packaging/common/postinstall-agent.sh
Normal file
@ -0,0 +1,73 @@
|
||||
#!/bin/sh
|
||||
|
||||
use_systemctl="True"
|
||||
systemd_version=0
|
||||
if ! command -V systemctl >/dev/null 2>&1; then
|
||||
use_systemctl="False"
|
||||
else
|
||||
systemd_version=$(systemctl --version | head -1 | cut -d ' ' -f 2)
|
||||
fi
|
||||
|
||||
service_name=emissary-agent
|
||||
|
||||
cleanup() {
|
||||
if [ "${use_systemctl}" = "False" ]; then
|
||||
rm -f /usr/lib/systemd/system/${service_name}.service
|
||||
else
|
||||
rm -f /etc/chkconfig/${service_name}
|
||||
rm -f /etc/init.d/${service_name}
|
||||
fi
|
||||
}
|
||||
|
||||
cleanInstall() {
|
||||
printf "\033[32m Post Install of an clean install\033[0m\n"
|
||||
if [ "${use_systemctl}" = "False" ]; then
|
||||
if command -V chkconfig >/dev/null 2>&1; then
|
||||
chkconfig --add ${service_name}
|
||||
fi
|
||||
|
||||
service ${service_name} restart || :
|
||||
else
|
||||
if [[ "${systemd_version}" -lt 231 ]]; then
|
||||
printf "\033[31m systemd version %s is less then 231, fixing the service file \033[0m\n" "${systemd_version}"
|
||||
sed -i "s/=+/=/g" /usr/lib/systemd/system/${service_name}.service
|
||||
fi
|
||||
printf "\033[32m Reload the service unit from disk\033[0m\n"
|
||||
systemctl daemon-reload || :
|
||||
printf "\033[32m Unmask the service\033[0m\n"
|
||||
systemctl unmask ${service_name} || :
|
||||
printf "\033[32m Set the preset flag for the service unit\033[0m\n"
|
||||
systemctl preset ${service_name} || :
|
||||
printf "\033[32m Set the enabled flag for the service unit\033[0m\n"
|
||||
systemctl enable ${service_name} || :
|
||||
systemctl restart ${service_name} || :
|
||||
fi
|
||||
}
|
||||
|
||||
upgrade() {
|
||||
printf "\033[32m Post Install of an upgrade\033[0m\n"
|
||||
}
|
||||
|
||||
# Step 2, check if this is a clean install or an upgrade
|
||||
action="$1"
|
||||
if [ "$1" = "configure" ] && [ -z "$2" ]; then
|
||||
action="install"
|
||||
elif [ "$1" = "configure" ] && [ -n "$2" ]; then
|
||||
action="upgrade"
|
||||
fi
|
||||
|
||||
case "$action" in
|
||||
"1" | "install")
|
||||
cleanInstall
|
||||
;;
|
||||
"2" | "upgrade")
|
||||
printf "\033[32m Post Install of an upgrade\033[0m\n"
|
||||
upgrade
|
||||
;;
|
||||
*)
|
||||
printf "\033[32m Alpine\033[0m"
|
||||
cleanInstall
|
||||
;;
|
||||
esac
|
||||
|
||||
cleanup
|
73
misc/packaging/common/postinstall-server.sh
Normal file
73
misc/packaging/common/postinstall-server.sh
Normal file
@ -0,0 +1,73 @@
|
||||
#!/bin/sh
|
||||
|
||||
use_systemctl="True"
|
||||
systemd_version=0
|
||||
if ! command -V systemctl >/dev/null 2>&1; then
|
||||
use_systemctl="False"
|
||||
else
|
||||
systemd_version=$(systemctl --version | head -1 | cut -d ' ' -f 2)
|
||||
fi
|
||||
|
||||
service_name=emissary-server
|
||||
|
||||
cleanup() {
|
||||
if [ "${use_systemctl}" = "False" ]; then
|
||||
rm -f /usr/lib/systemd/system/${service_name}.service
|
||||
else
|
||||
rm -f /etc/chkconfig/${service_name}
|
||||
rm -f /etc/init.d/${service_name}
|
||||
fi
|
||||
}
|
||||
|
||||
cleanInstall() {
|
||||
printf "\033[32m Post Install of an clean install\033[0m\n"
|
||||
if [ "${use_systemctl}" = "False" ]; then
|
||||
if command -V chkconfig >/dev/null 2>&1; then
|
||||
chkconfig --add ${service_name}
|
||||
fi
|
||||
|
||||
service ${service_name} restart || :
|
||||
else
|
||||
if [[ "${systemd_version}" -lt 231 ]]; then
|
||||
printf "\033[31m systemd version %s is less then 231, fixing the service file \033[0m\n" "${systemd_version}"
|
||||
sed -i "s/=+/=/g" /usr/lib/systemd/system/${service_name}.service
|
||||
fi
|
||||
printf "\033[32m Reload the service unit from disk\033[0m\n"
|
||||
systemctl daemon-reload || :
|
||||
printf "\033[32m Unmask the service\033[0m\n"
|
||||
systemctl unmask ${service_name} || :
|
||||
printf "\033[32m Set the preset flag for the service unit\033[0m\n"
|
||||
systemctl preset ${service_name} || :
|
||||
printf "\033[32m Set the enabled flag for the service unit\033[0m\n"
|
||||
systemctl enable ${service_name} || :
|
||||
systemctl restart ${service_name} || :
|
||||
fi
|
||||
}
|
||||
|
||||
upgrade() {
|
||||
printf "\033[32m Post Install of an upgrade\033[0m\n"
|
||||
}
|
||||
|
||||
# Step 2, check if this is a clean install or an upgrade
|
||||
action="$1"
|
||||
if [ "$1" = "configure" ] && [ -z "$2" ]; then
|
||||
action="install"
|
||||
elif [ "$1" = "configure" ] && [ -n "$2" ]; then
|
||||
action="upgrade"
|
||||
fi
|
||||
|
||||
case "$action" in
|
||||
"1" | "install")
|
||||
cleanInstall
|
||||
;;
|
||||
"2" | "upgrade")
|
||||
printf "\033[32m Post Install of an upgrade\033[0m\n"
|
||||
upgrade
|
||||
;;
|
||||
*)
|
||||
printf "\033[32m Alpine\033[0m"
|
||||
cleanInstall
|
||||
;;
|
||||
esac
|
||||
|
||||
cleanup
|
10
misc/packaging/openrc/emissary-agent.openrc.sh
Normal file
10
misc/packaging/openrc/emissary-agent.openrc.sh
Normal file
@ -0,0 +1,10 @@
|
||||
#!/sbin/openrc-run
|
||||
|
||||
command="/usr/bin/emissary"
|
||||
command_args="--config /etc/emissary/config.yml agent run"
|
||||
start_stop_daemon_args='--chdir /usr/share/emissary'
|
||||
supervisor=supervise-daemon
|
||||
|
||||
depend() {
|
||||
need net
|
||||
}
|
10
misc/packaging/openrc/emissary-server.openrc.sh
Normal file
10
misc/packaging/openrc/emissary-server.openrc.sh
Normal file
@ -0,0 +1,10 @@
|
||||
#!/sbin/openrc-run
|
||||
|
||||
command="/usr/bin/emissary"
|
||||
command_args="--config /etc/emissary/config.yml server run"
|
||||
start_stop_daemon_args='--chdir /usr/share/emissary'
|
||||
supervisor=supervise-daemon
|
||||
|
||||
depend() {
|
||||
need net
|
||||
}
|
20
misc/packaging/openwrt/emissary-agent.init.sh
Normal file
20
misc/packaging/openwrt/emissary-agent.init.sh
Normal file
@ -0,0 +1,20 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
USE_PROCD=1
|
||||
START=50
|
||||
STOP=50
|
||||
|
||||
start_service() {
|
||||
local config_file="/etc/emissary/agent.yml"
|
||||
procd_open_instance emissary-agent
|
||||
procd_set_param command /usr/bin/emissary
|
||||
procd_append_param command --workdir /usr/share/emissary
|
||||
procd_append_param command --config "$config_file"
|
||||
procd_append_param command agent run
|
||||
procd_set_param respawn ${respawn_threshold:-3600} ${respawn_timeout:-5} ${respawn_retry:-5}
|
||||
procd_set_param file "$config_file"
|
||||
procd_set_param stdout 1
|
||||
procd_set_param stderr 1
|
||||
procd_set_param pidfile /var/run/emissary-agent.pid
|
||||
procd_close_instance
|
||||
}
|
12
misc/packaging/systemd/emissary-agent.systemd.service
Normal file
12
misc/packaging/systemd/emissary-agent.systemd.service
Normal file
@ -0,0 +1,12 @@
|
||||
[Unit]
|
||||
Description=emissary agent service
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
Restart=always
|
||||
WorkingDirectory=/usr/share/emissary
|
||||
ExecStart=/usr/bin/emissary --config /etc/emissary/config.yml agent run
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
12
misc/packaging/systemd/emissary-server.systemd.service
Normal file
12
misc/packaging/systemd/emissary-server.systemd.service
Normal file
@ -0,0 +1,12 @@
|
||||
[Unit]
|
||||
Description=emissary server service
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
Restart=always
|
||||
WorkingDirectory=/usr/share/emissary
|
||||
ExecStart=/usr/bin/emissary --config /etc/emissary/config.yml server run
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
Reference in New Issue
Block a user