towry
9/3/2014 - 5:34 AM

rj

rj

#! /bin/bash

curDir=$(cd "$(dirname "$0")"; pwd);
arg="-u12345678 -p12345 -d0 -S1";
until [ $# -eq 0 ]
do
	opt=$1;
	if [ "${opt/ /}" != "$opt" ]; then 
		arg="$arg \"$opt\"";
	else
		arg="$arg $opt";
	fi
        shift
done

function is64BIT()
{
	os=$(getconf LONG_BIT);
	if [ $os != "64" ];  then
		return 0;
	fi
	return 1;
}

function main()
{
	is64BIT;	
	if [ $? != "1" ];  then	
		chmod +x /opt/rj/x86/rjsupplicant 2>&-;
		cd /opt/rj/x86/
		nohup sh -c "/opt/rj/x86/rjsupplicant $arg" > /dev/null 2>&1 &
	else
		chmod +x /opt/rj/x64/rjsupplicant 2>&-;
		cd /opt/rj/x64/
		nohup sh -c "/opt/rj/x64/rjsupplicant $arg" > /dev/null 2>&1 &
	fi	
	
}
main;
exit 0;
#!/bin/bash
# Run the rjsupplicant
# version 2.0.0

PACKAGE_NAME=rj
PACKAGE_DESC="rj application"
PACKAGE_DIR="/opt/rj"
ARG="-uXXXX -pXXXX -d0 -S1"

function is64BIT()
{
	os=$(getconf LONG_BIT);
	if [ $os != "64" ]; then
		return 0;
	fi
	return 1;
}

function isExcutable()
{
	if [[ -x $1 ]] ; then
		# do nothing
		:
	else
		chmod +x $1 2>&-;
	fi
}

function start()
{
	echo "Starting ${PACKAGE_NAME}"
	[[ is64BIT == 1 ]] && xxx="x64" || xxx="x86"
	isExcutable $PACKAGE_DIR/$xxx/rjsupplicant
	cd $PACKAGE_DIR/$xxx
	nohup sh -c "./rjsupplicant ${ARG}" > /dev/null 2>&1 &
	echo "rj is running"
}

function stop()
{
	echo "Stopping ${PACKAGE_NAME}, it may take a while."
	kill -9 `ps -e | grep rj | grep -v grep | awk '{print $1}'` > /dev/null 2>&1 || true
}

function restart()
{
	stop 
	sleep 1
	start
}

function usage()
{
	N=$(basename "$0")
	echo "Usage: [sudo] $N {start|stop|restart}" >&2
	exit 1
}

if [ "$(id -u)" != "0" ]; then
	echo "please use sudo to run ${PACKAGE_NAME}"
	exit 0
fi

case "$1" in 
	'' | start)
		start
		;;
	stop)
		stop
		;;
	restart)
		restart
		;;
	*)
		usage
		;;
esac

/etc/network/interfaces

append the following line:

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 0.0.0.0
netmask 255.255.255.0
gateway 0.0.0.0

dns-nameserver 1.1.1.1

`cd /etc/resolvconf/resolv.conf.d/ && vi base