1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
|
#!/bin/sh -e
usage="
Usage: $0 [OPTIONS]
Installs PrimeSense Sensor Driver to current machine.
-i,--install
Installs PrimeSense Sensor Driver (default mode)
-u,--uninstall
Uninstalls PrimeSense Sensor Driver.
-c,--cross-compile-rootfs <path>
Used for cross-compiling. Installs PrimeSense Sensor Driver to <path> instead of '/'.
-h,--help
Shows this help screen.
"
OS_NAME=`uname -s`
case $OS_NAME in
Darwin)
MODULES="libXnDeviceSensorV2.dylib libXnDeviceFile.dylib"
;;
*)
MODULES="libXnDeviceSensorV2.so libXnDeviceFile.so"
;;
esac
RULES_FILE="55-primesense-usb.rules"
# create file list
SCRIPT_DIR=`pwd`/`dirname $0`
LIB_FILES=`ls $SCRIPT_DIR/Lib/*`
BIN_FILES=`ls $SCRIPT_DIR/Bin/*`
rootfs=
# parse command line
while [ "$1" ]; do
case $1 in
-i|--install)
install=yes
;;
-u|--uninstall)
uninstall=yes
;;
-c|--cross-staging-dir)
shift
rootfs=$1
;;
-h|--help)
echo "$usage"
exit 0
;;
*)
echo "Unrecognized option $1"
exit 1
esac
shift
done
# default mode is install
if [ ! "$install" = yes ] && [ ! "$uninstall" = yes ]; then
install=yes
fi
# validity check
if [ "$install" = yes ] && [ "$uninstall" = yes ]; then
echo "-i and -u flags cannot be used together!"
exit 1
fi
INSTALL_LIB=$rootfs/usr/lib
INSTALL_BIN=$rootfs/usr/bin
INSTALL_ETC=$rootfs/usr/etc/primesense
INSTALL_RULES=$rootfs/etc/udev/rules.d
SERVER_LOGS_DIR=$rootfs/var/log/primesense/XnSensorServer
# make all calls into OpenNI run in this filesystem
export OPEN_NI_INSTALL_PATH=$rootfs
# make sure the staging dir OpenNI is the one being run
export LD_LIBRARY_PATH=$INSTALL_LIB
if [ "$install" = yes ]; then
printf "Installing PrimeSense Sensor\n"
printf "****************************\n\n"
# create config dir
printf "creating config dir $INSTALL_ETC..."
mkdir -p $INSTALL_ETC
printf "OK\n"
# Copy shared libraries
printf "copying shared libraries..."
cp $LIB_FILES $INSTALL_LIB
printf "OK\n"
# Copy executables
printf "copying executables..."
cp $BIN_FILES $INSTALL_BIN
printf "OK\n"
# register modules
for module in $MODULES; do
printf "registering module '$module' with OpenNI..."
$INSTALL_BIN/niReg -r $INSTALL_LIB/$module $INSTALL_ETC
printf "OK\n"
done
# copy config file
printf "copying server config file..."
cp Config/GlobalDefaults.ini $INSTALL_ETC
printf "OK\n"
# make server run as root
printf "setting uid of server..."
chown root $INSTALL_BIN/XnSensorServer
chmod +s $INSTALL_BIN/XnSensorServer
printf "OK\n"
# create server log dir
printf "creating server logs dir..."
mkdir -p $SERVER_LOGS_DIR
# make this dir readable and writable by all (we allow anyone to delete logs)
chmod a+w $SERVER_LOGS_DIR
printf "OK\n"
if [ "`uname -s`" != "Darwin" ]; then
# install USB rules (so that PrimeSense sensors will be mounted with write permissions)
printf "installing usb rules..."
cp Install/$RULES_FILE $INSTALL_RULES
printf "OK\n"
fi
printf "\n*** DONE ***\n\n"
elif [ "$uninstall" = yes ]; then
printf "Uninstalling PrimeSense Sensor\n"
printf "******************************\n\n"
# unregister modules
for module in $MODULES; do
printf "unregistering module '$module' from OpenNI..."
if $INSTALL_BIN/niReg -u $INSTALL_LIB/$module; then
printf "OK\n"
fi
done
# delete shared libraries
printf "removing shared libraries..."
for filename in $LIB_FILES; do
rm -f $INSTALL_LIB/`basename $filename`
done
printf "OK\n"
# delete executables
printf "removing executables..."
for filename in $BIN_FILES; do
rm -f $INSTALL_BIN/`basename $filename`
done
printf "OK\n"
# delete config dir
printf "removing config dir..."
rm -rf $INSTALL_ETC
printf "OK\n"
if [ "`uname -s`" != "Darwin" ]; then
# remove USB rules
printf "removing usb rules..."
rm -f $INSTALL_RULES/$RULES_FILE
printf "OK\n"
fi
printf "\n*** DONE ***\n\n"
fi
|