From the current svn code the ssh-test functions do look like here :
Code:
##############################################
# Check ssh comunication for addon #
##############################################
if ( Enable_Startup_Addon == 0):
# We have a ssh configuration that should work ....
# But should working and working properly are two diffrent things ,-)
state_ssh = OSCheckSSH()
if (state_ssh == 1):
GUIInfo(0,__language__(33321))
if (__verbose__ == "true"):
GUIlog ("please do configure ssh-server for login without any passwords")
GUIlog ("This addon do not start until ssh communication is working properly for the current user")
GUIlog ("Addon do exit now ...")
Enable_Startup_Addon = Enable_Startup_Addon + 1
And the test istself is very basic ....
Code:
#########################################################
# Function : OSCheckSSH #
#########################################################
# Parameter : none #
# #
# Returns : #
# #
# 1 Test failed #
# 0 Test successfull #
# #
#########################################################
def OSCheckSSH():
global __configLinux__
global __verbose__
if (os.path.exists(__configLinux__[39])):
os.remove(__configLinux__[39])
OSRun( "check-ssh.sh ",True,False)
time.sleep(2)
if (os.path.exists(__configLinux__[39])):
return 0
else:
return 1
#########################################################
This code depends on a few things .....
the user from the settings (example : xbmc) can start any ssh-command without any password.
It does execute the shell-script "check-ssh.sh" and does wait for 2 secounds.
Code:
#!/bin/bash
###########################################################
# scriptname : check_ssh.sh #
###########################################################
# This script is part of the addon swiss-army-knife for #
# xbmc and is licenced under the gpl-licence #
# http://code.google.com/p/swiss-army-knife/ #
###########################################################
# author : [email protected] #
# parameters : none #
# description : #
# test ssh connection #
###########################################################
SCRIPTDIR="$HOME/.xbmc/addons/script.video.swiss.army.knife/shell-linux"
cd "$SCRIPTDIR"
###########################################################
# #
# Check that not user root is running this script #
# #
###########################################################
if [ "$UID" == 0 ] ; then
clear
echo This script should not be executed as user root !
echo You have to remove this lines to run this script as user
echo root, what is by the way not recommanded !!
echo
echo ----------------------- script rc=254 ---------------------------
echo -----------------------------------------------------------------
exit 254
fi
###########################################################
###########################################################
# #
# We can only run with bash as default shell #
# #
###########################################################
SHELLTEST="/bin/bash"
if [ $SHELL != $SHELLTEST ] ; then
clear
echo
echo only bash shell is supported by this shell-script.
echo It looks like you are using something other than /bin/bash.
echo
echo ----------------------- script rc=255 ---------------------------
echo -----------------------------------------------------------------
exit 255
fi
###########################################################
###########################################################
# #
# Show disclaimer / copyright note on top of the screen #
# #
###########################################################
clear
echo
echo ----------------------------------------------------------------------------
SCRIPT=$(basename $0)
echo "script :" $SCRIPT
cat version
echo "copyright : (C) <2010-2011> <[email protected]>"
cd "$SCRIPTDIR" && echo changed to $SCRIPTDIR
echo ----------------------------------------------------------------------------
###########################################################
###########################################################
# #
# Definition of files and internal variables #
# #
###########################################################
ZERO=0
E_SUID0=254
E_WRONG_SHELL=255
###########################################################
# On startup we do clean the ssh-command directory
rm $HOME/swiss.army.knife/ssh/* > /dev/null 2>&1
rm $HOME/.xbmc/userdata/addon_data/script.video.swiss.army.knife/log/ssh-test > /dev/null 2>&1
echo 1 > $HOME/.xbmc/userdata/addon_data/script.video.swiss.army.knife/log/ssh-test
echo
echo ----------------------- script rc=0 -----------------------------
echo -----------------------------------------------------------------
exit $ZERO
###########################################################
After 2 secounds the file $HOME/.xbmc/userdata/addon_data/script.video.swiss.army.knife/log/ssh-test
If this file do not exist .... there is a problem .-(