Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #7050: Add a rudder server disable command #21

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions share/commands/agent-disable
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,41 @@
# @description forbid rudder-agent to be run by cron or service
# @man This is useful when you want to temporarily prevent your Rudder agent
# @man from doing any modification to your system.
# @man +
# @man +
# @man *Options*:
# @man +
# @man *-s*: stop rudder-agent in addition to disabling it

while getopts "s" opt; do
case $opt in
s)
STOP=y
;;
esac
done

touch /opt/rudder/etc/disable-agent
if [ -x /usr/bin/stopsrc ]
then
CMD="stopsrc -s rudder-agent"
elif [ -x /usr/sbin/service ]
then
CMD="service rudder-agent stop"
elif [ -x /etc/init.d/rudder-agent ]
then
CMD="/etc/init.d/rudder-agent stop"
fi
if [ "${STOP}" = "y" ]
then
if [ -n "${CMD}" ]
then
$CMD
else
echo "Don't know how to stop rudder agent." 1>&2
echo "Agent not stopped !" 1>&2
fi
else
echo "rudder-agent has been enabled but not started, wait for next cron run"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/enabled/disabled/ + s/started/stopped/ + remove the bit about a cron run

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I propose to add "run rudder agent disable -s to stop the agent" too

fi

19 changes: 19 additions & 0 deletions share/commands/server-disable
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh
# @description forbid Rudder to distribute new policies as a server
# @man This is useful when you want to temporarily prevent your Rudder server
# @man from doing any modification on your agents
# @man +
# @man +
# @man *Options*:
# @man +
# @man *--policy-server*: disable the policy-server component

if [ -z "$1" ] || [ "$1" != "--policy-server" ]
then
echo "Usage rudder server disable [option]"
exit 1
fi

# --policy-server
`dirname "$0"`/agent-disable -s

15 changes: 15 additions & 0 deletions share/commands/server-enable
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh
# @description re-enable a disabled Rudder server
# @man +
# @man *Options*:
# @man +
# @man *--policy-server*: disable the policy-server component

if [ -z "$1" ] || [ "$1" != "--policy-server" ]
then
echo "Usage rudder server enable [option]"
exit 1
fi

# --policy-server
`dirname "$0"`/agent-enable -s