summaryrefslogtreecommitdiff
path: root/src/flufigut-client.sh
diff options
context:
space:
mode:
Diffstat (limited to 'src/flufigut-client.sh')
-rwxr-xr-xsrc/flufigut-client.sh43
1 files changed, 34 insertions, 9 deletions
diff --git a/src/flufigut-client.sh b/src/flufigut-client.sh
index 8ac58ce..91591fd 100755
--- a/src/flufigut-client.sh
+++ b/src/flufigut-client.sh
@@ -28,29 +28,51 @@
# along with flufigut. If not, see <http://www.gnu.org/licenses/>.
#
-# INSTALLATION
-# - copy script to /usr/local/bin
-# - add ssh key to authorized keys of flumotion user with options:
-# command="/usr/local/bin/flufigut-client.sh",no-X11-forwarding,no-agent-forwarding,no-port-forwarding
-# -
-
NAME="flumotion"
LOGFILE="/var/log/flumotion/service.log"
DAEMON="/usr/sbin/$NAME"
DAEMON_ARGS="-d 3 -l $LOGFILE"
CONF_DIR="/etc/flumotion"
+
+if [ "install" = "$1" ]; then
+ UID=`/usr/bin/id -u`
+ if [ $UID -ne 0 ]; then
+ echo "ERROR: this script must run as root for install installation."
+ exit 1
+ fi
+ cp $0 /usr/local/bin
+ getent passwd flufigut > /dev/null 2>&1
+ if [ $? -ne 0 ]; then
+ echo -n "copy&paste public key and press enter: "
+ read pubkey
+ if [ -z "$pubkey" ]; then
+ echo "ERROR: no keyfile given"
+ exit 1
+ fi
+ adduser flufigut --disabled-password --home /var/lib/flufigut --gecos "flufigut management" --shell "/bin/sh"
+ mkdir -p /var/lib/flufigut/.ssh
+ echo 'command="/usr/local/bin/flufigut-client.sh",no-X11-forwarding,no-agent-forwarding,no-port-forwarding '$pubkey > /var/lib/flufigut/.ssh/authorized_keys
+ chown -R flufigut:flufigut /var/lib/flufigut/.ssh
+ chmod 600 /var/lib/flufigut/.ssh/authorized_keys
+ echo "flufigut ALL = (flumotion) NOPASSWD: $DAEMON" >> /etc/sudoers
+ fi
+ echo "successfully installed flufigut client."
+
+ exit 0
+fi
+
start_instance() {
type="$1"
name="$2"
- $DAEMON $DAEMON_ARGS start $type $name
+ sudo -u flumotion $DAEMON $DAEMON_ARGS start $type $name
return "$?"
}
stop_instance() {
type="$1"
name="$2"
- $DAEMON $DAEMON_ARGS stop $type $name
+ sudo -u flumotion $DAEMON $DAEMON_ARGS stop $type $name
return "$?"
}
@@ -76,8 +98,11 @@ case "$command" in
echo -n "starting ..."
echo "ok."
;;
+ scp)
+ $SSH_ORIGINAL_COMMAND
+ ;;
*)
- echo "Unknown command"
+ echo "Unknown command: '$command'"
exit 1
;;
esac