Created
February 13, 2012 08:33
-
-
Save lqez/1815068 to your computer and use it in GitHub Desktop.
cloudfuse start/stop script for ucloudbiz.olleh.com storage service.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /bin/sh | |
| ### BEGIN INIT INFO | |
| # Provides: cloudfuse | |
| # Should-Start: $named | |
| # Default-Start: 2 3 4 5 | |
| # Default-Stop: | |
| # Short-Description: fast remote file copy program daemon | |
| # Description: Cloudfuse is a FUSE application which provides access to | |
| # Rackspace's Cloud Files (or any installation of Swift). | |
| # This provides cloudfuse daemon functionality. | |
| ### END INIT INFO | |
| set -e | |
| # /etc/init.d/cloudfuse: start and stop the cloudfuse daemon | |
| DAEMON=/usr/local/bin/cloudfuse | |
| # I built [cloudfuse] from source code and put it into /usr/local/bin directory. Change it with your favor. | |
| CF_GID=Your GID | |
| CF_USERNAME=Your Username | |
| CF_API_KEY=Your API Key | |
| CF_AUTHURL=Your Service URL | |
| # I used [https://ssproxy.ucloudbiz.olleh.com/auth/v1.0] for ucloud storage service | |
| CF_MOUNTPOINT=Your Mount Point | |
| test -x $DAEMON || exit 0 | |
| . /lib/lsb/init-functions | |
| export PATH="${PATH:+$PATH:}/usr/sbin:/sbin" | |
| cloudfuse_start() { | |
| PID=$(pidof cloudfuse) || true | |
| if [ -n "$PID" ]; then | |
| echo "cloudfuse is already running (pid $PID)." | |
| exit 0 | |
| else | |
| if start-stop-daemon --start --quiet --background \ | |
| --exec $DAEMON \ | |
| -- -o umask=0007,gid=$CF_GID,allow_other,username=$CF_USERNAME,api_key=$CF_API_KEY,authurl=$CF_AUTHURL "$CF_MOUNTPOINT" | |
| then | |
| rc=0 | |
| sleep 1 | |
| PID=$(pidof cloudfuse) || true | |
| if [ -z "$PID" ]; then | |
| log_failure_msg "cloudfuse daemon failed to start" | |
| rc=1 | |
| fi | |
| else | |
| rc=1 | |
| fi | |
| if [ $rc -eq 0 ]; then | |
| log_end_msg 0 | |
| else | |
| log_end_msg 1 | |
| fi | |
| fi | |
| } # cloudfuse_start | |
| cloudfuse_stop() { | |
| umount "$CF_MOUNTPOINT" | |
| log_end_msg $? | |
| } #cloudfuse_stop | |
| case "$1" in | |
| start) | |
| log_daemon_msg "Starting cloudfuse daemon" | |
| cloudfuse_start | |
| ;; | |
| stop) | |
| log_daemon_msg "Stopping cloudfuse daemon" | |
| cloudfuse_stop | |
| ;; | |
| restart) | |
| set +e | |
| log_daemon_msg "Restarting cloudfuse daemon" | |
| PID=$(pidof cloudfuse) || true | |
| if [ -n "$PID" ]; then | |
| cloudfuse_stop | |
| sleep 1 | |
| else | |
| log_warning_msg "cloudfuse daemon not running, attempting to start." | |
| fi | |
| cloudfuse_start | |
| ;; | |
| status) | |
| PID=$(pidof cloudfuse) || true | |
| if [ -n "$PID" ]; then | |
| echo "cloudfuse daemon is running (pid $PID)." | |
| exit 0 | |
| else | |
| echo "cloudfuse daemon is NOT running." | |
| exit 1 | |
| fi | |
| exit $? # notreached due to set -e | |
| ;; | |
| *) | |
| echo "Usage: /etc/init.d/cloudfuse {start|stop|restart|status}" | |
| exit 1 | |
| esac | |
| exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment