#!/bin/bash
IUSER=$1
HOME_PATH="/home/$IUSER/simba/server"
if [ ! -d ${HOME_PATH} ];then
		mkdir -p ${HOME_PATH}/{backup,logs,etc}
fi
if [ -d ${HOME_PATH} ];then
	cat ./sh/doc/whhsn.x > /tmp/whhsn.x
	cat ./sh/doc/whhsn.y > /tmp/whhsn.y
	cat /tmp/whhsn.x > ${HOME_PATH}/autostartup.sh 
	cat /tmp/whhsn.y > ${HOME_PATH}/stop.sh
	chmod +x ${HOME_PATH}/*.sh
	chown $IUSER:$IUSER ${HOME_PATH%/*}/ -R #拿掉最后一个/右边的字符串
	rm -rf /tmp/whhsn*
	ln -s /lib/systemd/system/rc.local.service /etc/systemd/system/rc.local.service
	cp ./sh/doc/rc.local /etc/rc.local
	sed -i "s/exit 0//g" /etc/rc.local
	echo "#sudo -u $IUSER /home/$IUSER/simba/server/autostartup.sh" >> /etc/rc.local
	echo "exit 0" >> /etc/rc.local
	chmod 755 /etc/rc.local
	echo "add_shell install ok" 
	echo "add_shell install ok" >>/home/start.log
else
	echo  ${HOME_PATH} not found
fi
