We are in the process of migrating this forum. A new space will be available soon. We are sorry for the inconvenience.

Debian 7 HubiC cant start/login


miguelferreira
04-17-2014, 01:25 PM
this script works 99% in all debian server that i've tested
--------------------------------------------------------
Code:
#!/bin/bash
### BEGIN INIT INFO
# Provides:          skeleton
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: hubic
# Description:       This file should be used to construct scripts to be
#                    placed in /etc/init.d.
### END INIT INFO

# Author: Miguel Ferreira 
#
# Do NOT "set -e"

# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="Armazenamento online para os seus ficheiros"
NAME=hubic
DAEMON=/usr/sbin/$NAME
SCRIPTNAME=/etc/init.d/$NAME

################ CONFIG ################
RUNAS="root"
#ainda não funciona
PASSWORD_PATH="$(readlink -m ~/.config/hubiC/pw)"
#ficheiro com a password (convem ser chmod 600 para mais ninguem ler)
EMAIL="your-email@domain.com"
#email de login no hubic
SYNC_DIR="$(readlink -m ~/HubiC)"
#pasta a sincronizar
########################################


# Exit if the package is not installed
[ -x "$(which hubic)" ] || exit 0
[ -x "$(which dbus-daemon)" ] || exit 0
	


# Read configuration variable file if it is present
#[ -r /etc/default/$NAME ] && . /etc/default/$NAME

# Load the VERBOSE setting and other rcS variables
#. /lib/init/vars.sh

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
# and status_of_proc is working.
. /lib/lsb/init-functions


get_dbus()
{
	DBUS_SESSION_BUS_PID="$(cat ~/.config/dbus.pid)"
	DBUS_SESSION_BUS_ADDRESS="$(cat ~/.config/dbus.address)"
}
export_dbus()
{
	echo "Run this:"
	echo "export DBUS_SESSION_BUS_PID="$(cat ~/.config/dbus.pid)""
	echo "export DBUS_SESSION_BUS_ADDRESS="$(cat ~/.config/dbus.address)""
}


do_start()
{
	status=0
	do_dbus_start
	if [ "$?" = 0  ]
	then
		get_dbus
		DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS hubic login --password_path="$PASSWORD_PATH" $EMAIL "$SYNC_DIR" 2> /dev/null || status="$?"
		if [ "$status" = 0  ]
		then 
			return 0
		else
			return 1
		fi
	else
		return 1
	fi

}



do_dbus_start()
{
	dbus-daemon --fork --print-pid 4 --print-address 6 --session 4>~/.config/dbus.pid 6>~/.config/dbus.address
	get_dbus
	return 0

}
do_dbus_stop()
{
	get_dbus
	kill $DBUS_SESSION_BUS_PID 2>/dev/null
	echo "" > ~/.config/dbus.pid
	echo "" > ~/.config/dbus.address
	return 0
}

do_status()
{
	get_dbus
	status=0
	DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS hubic status 2> /dev/null || status="$?"
		if [ "$status" = 0  ]
		then 
			[ "$VERBOSE" != no ] && log_daemon_msg "$NAME: GetStatus "
			return 0
		else
			[ "$VERBOSE" != no ] && log_daemon_msg "$NAME: GetStatus "
			return 1
		fi
}

do_logout()
{
	get_dbus
	status=0
	DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS hubic logout 2> /dev/null || status="$?"
	if [ "$status" = 0  ]
	then 
		return 0
	else
		return 1
	fi
}

do_stop()
{
	get_dbus
	DBUS_SESSION_BUS_ADDRESS="$DBUS_SESSION_BUS_ADDRESS" hubic stop 2>/dev/null
	do_dbus_stop
	return 0
}



case "$1" in
  start)
	[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
	do_start
	case "$?" in
		0) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
		1) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
	esac	
	;;
  stop)
	[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
	do_stop
	case "$?" in
		0) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
		1) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
	esac
	;;
  status)
	do_status
	case "$?" in
		0) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
		1) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
	esac	
	;;
  login)
	[ "$VERBOSE" != no ] && log_daemon_msg "Login $DESC" "$NAME"
	do_start
	case "$?" in
		0) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
		1) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
	esac	
	;;
  logout)
	[ "$VERBOSE" != no ] && log_daemon_msg "Logout $DESC" "$NAME"
	do_logout
	case "$?" in
		0) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
		1) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
	esac	
	;;
	exportdbus)
		export_dbus
	;;
	*)
	echo "Usage: $SCRIPTNAME {start|stop|status|login|logout|exportdbus}" >&2
	exit 3
	;;
esac

:

miguelferreira
04-16-2014, 02:39 PM
my hubic dont work in linux....



# dbus-launch --auto-syntax
DBUS_SESSION_BUS_ADDRESS='unix:abstract=/tmp/dbus-cxxEIdYN8J,guid=36f9e8ea30f4c5086fbf04b7534e8273';
export DBUS_SESSION_BUS_ADDRESS;
DBUS_SESSION_BUS_PID=27824;
# DBUS_SESSION_BUS_ADDRESS='unix:abstract=/tmp/dbus-cxxEIdYN8J,guid=36f9e8ea30f4c5086fbf04b7534e8273';
# echo $DBUS_SESSION_BUS_ADDRESS
unix:abstract=/tmp/dbus-cxxEIdYN8J,guid=36f9e8ea30f4c5086fbf04b7534e8273
# hubic status
State: NotConnected
Up: 0 B/s (0 B/s) Down: 0 B/s (0 B/s)

Last events:
[16-04-2014 14:16:00|Info] Authentication in progress


# hubic login HubiC/
Password:
[Error] Wrong HTTP response. (0x00)
Command failed: System.InvalidOperationException: Cannot log in.

------------------------- Log From application ------------------------
[INFO | 16-04-2014 14:24:43 | Ovh.Hubic.Backend.HubicAccountHandler..ctor] Initialize backend: Application=hubic-sync, Version=1.2.4.35, OS=unix 3.2.0.4
[INFO | 16-04-2014 14:24:44 | Ovh.Hubic.Sync.Linux.CLI.Server.MainLoop] Application starts (Version: 1.2.4.35-64; Platform: Unix 3.2.0.4)
[INFO | 16-04-2014 14:25:04 | Ovh.Hubic.Backend.Swift.SwiftCredentialsHolder.Ref reshCredentials] Renew Swift token...
[WARN | 16-04-2014 14:25:09 | Ovh.Hubic.Sync.Model.OnLogin] Can't connect: Ovh.Hubic.Interface.Exceptions.StorageError: Wrong HTTP response. (0x00)
at Ovh.Hubic.Backend.Swift.SwiftClient.CheckListingRe sponse (IHttpResponse resp, Boolean isAccount) [0x00000] in :0
at Ovh.Hubic.Backend.Swift.HubicSwiftAccount.Unprotec tedInitializeContainers (Ovh.Hubic.Backend.Swift.SwiftClient c) [0x00000] in :0
at Ovh.Hubic.Backend.Swift.HubicSwiftAccount..ctor (HubicBackend.API.OAuth api, Ovh.API.Account.Account account, Ovh.Hubic.Backend.HubicAccountHandler accountHandler) [0x00000] in :0
at Ovh.Hubic.Backend.HubicAccountHandler.Connect (System.String login, System.String password) [0x00000] in :0
at Ovh.Hubic.Sync.Model+c__AnonStorey34.<>m __71 () [0x00000] in :0
at Ovh.Hubic.Sync.Model.OnLogin (System.Func`1 connector) [0x00000] in :0