first commit
This commit is contained in:
157
archiso/airootfs/home/smart/SmartOrganizer/common/MiaozhenProbe/install.sh
Executable file
157
archiso/airootfs/home/smart/SmartOrganizer/common/MiaozhenProbe/install.sh
Executable file
@@ -0,0 +1,157 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "\
|
||||
===================================================
|
||||
MiaozhenProbe Installation
|
||||
===================================================
|
||||
"
|
||||
|
||||
# 脚本所在目录 绝对路径
|
||||
ROOT_PATH="/home/smart/SmartOrganizer"
|
||||
. ${ROOT_PATH}/lib.conf
|
||||
|
||||
PACKAGE_PATH="/home/Miaozhen"
|
||||
PACKAGE_NAME="MiaozhenProbe"
|
||||
SERVICE_NAME="MiaozhenProbeService"
|
||||
|
||||
|
||||
CURRENT_VERSION=""
|
||||
TARGET_VERSION="${1}"
|
||||
|
||||
if [[ -z ${TARGET_VERSION} ]]; then
|
||||
echo "Argument: TARGET_VERSION is needed!"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
#version_compare()
|
||||
#{
|
||||
# source=(${1//./ })
|
||||
# target=(${2//./ })
|
||||
# for ((i=0; i<${#source[@]}; i++)); do
|
||||
# if [[ ${source[i]} == ${target[i]} ]]; then
|
||||
# continue
|
||||
# fi
|
||||
#
|
||||
# if [[ ${source[i]} -lt ${target[i]} ]]; then
|
||||
# echo -1
|
||||
# return
|
||||
# elif [[ ${source[i]} -gt ${target[i]} ]]; then
|
||||
# echo 1
|
||||
# return
|
||||
# fi
|
||||
# done
|
||||
# echo 0
|
||||
#}
|
||||
|
||||
#PACKAGE_URL="http://axis-config.oss-cn-beijing.aliyuncs.com/MiaozhenProbe/MiaozhenProbe.jar"
|
||||
|
||||
# Create working path
|
||||
#echo "Create working path ${PACKAGE_PATH}"
|
||||
|
||||
#mkdir -p ${PACKAGE_PATH}
|
||||
pushd ${PACKAGE_PATH} > /dev/null
|
||||
|
||||
if [[ -f ".version" ]]; then
|
||||
CURRENT_VERSION="$(cat .version)"
|
||||
fi
|
||||
|
||||
if [[ -n ${CURRENT_VERSION} ]]; then
|
||||
echo "current_version:"${CURRENT_VERSION}" target_version:"${TARGET_VERSION}
|
||||
if [[ $(version_compare ${CURRENT_VERSION} ${TARGET_VERSION}) != -1 ]]; then
|
||||
echo "No upgrade required"
|
||||
popd > /dev/null
|
||||
exit 2
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Upgrade start >>>"
|
||||
|
||||
# Download
|
||||
#echo "Downloading [ MiaozhenProbe.jar ] from [ ${PACKAGE_URL} ] ..."
|
||||
#wget -q ${PACKAGE_URL} -O ./${PACKAGE_NAME}.jar
|
||||
#echo "Download ... successed!"
|
||||
\cp -r ${PACKAGE_PATH}/repo/last/. ${PACKAGE_PATH}
|
||||
chmod og+x ${PACKAGE_NAME}.jar
|
||||
echo "USE_START_STOP_DAEMON=false" > ${PACKAGE_NAME}.conf
|
||||
|
||||
if [[ $(getSystemVersion ) -eq 6 ]]; then
|
||||
|
||||
# Add to system service and auto startup
|
||||
chkconfig ${SERVICE_NAME} off
|
||||
chkconfig --del ${SERVICE_NAME}
|
||||
rm -f /etc/init.d/${SERVICE_NAME}
|
||||
|
||||
echo "Register to system service ... successed!"
|
||||
ln -s /home/Miaozhen/${PACKAGE_NAME}.jar /etc/init.d/${SERVICE_NAME}
|
||||
chkconfig --add ${SERVICE_NAME}
|
||||
chkconfig ${SERVICE_NAME} on
|
||||
|
||||
echo "Register to auto start ... successed!"
|
||||
# startup
|
||||
echo "Start service ... successed!"
|
||||
# service ${SERVICE_NAME} restart
|
||||
|
||||
# set self-starting
|
||||
netstat -anp | grep ${SERVICE_NAME} &> /dev/null
|
||||
if [[ $? -ne 0 ]]; then
|
||||
cat > ${PACKAGE_PATH}/startup.sh <<EOF
|
||||
export JAVA_HOME=/opt/soft/java
|
||||
export PATH=$JAVA_HOME/bin/:$PATH
|
||||
nohup java -jar ${PACKAGE_PATH}/{PACKAGE_NAME}.jar > /dev/null 2>&1 &
|
||||
chmod 777 /home/Miaozhen/logs/*.log
|
||||
|
||||
EOF
|
||||
chmod og+x ${PACKAGE_PATH}/startup.sh
|
||||
echo "sh /home/Miaozhen/startup.sh" >> /etc/rc.local
|
||||
fi
|
||||
|
||||
else
|
||||
|
||||
# Add to system service and auto startup
|
||||
systemctl stop ${SERVICE_NAME}
|
||||
systemctl disable ${SERVICE_NAME}
|
||||
|
||||
cat > "/usr/lib/systemd/system/${SERVICE_NAME}.service" <<EOF
|
||||
#!/bin/sh
|
||||
[Unit]
|
||||
Description=${SERVICE_NAME}
|
||||
After=syslog.target network.target remote-fs.target nss-lookup.target
|
||||
[Service]
|
||||
Type=forking
|
||||
ExecStart=${PACKAGE_PATH}/${SERVICE_NAME}-start.sh
|
||||
ExecStop=${PACKAGE_PATH}/${SERVICE_NAME}-stop.sh
|
||||
PrivateTmp=true
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
cat > ${PACKAGE_PATH}/${SERVICE_NAME}-start.sh <<EOF
|
||||
#!/bin/sh
|
||||
export JAVA_HOME=/opt/soft/java
|
||||
export PATH=$JAVA_HOME/bin:$PATH
|
||||
nohup java -jar ${PACKAGE_PATH}/${PACKAGE_NAME}.jar > /dev/null 2>&1 &
|
||||
echo $! > /var/run/"${SERVICE_NAME}".pid
|
||||
EOF
|
||||
cat > ${PACKAGE_PATH}/${SERVICE_NAME}-stop.sh <<EOF
|
||||
#!/bin/sh
|
||||
PID=$(cat /var/run/"${SERVICE_NAME}".pid)
|
||||
kill -9 $PID
|
||||
EOF
|
||||
|
||||
chmod +x ${PACKAGE_PATH}/${SERVICE_NAME}-start.sh
|
||||
chmod +x ${PACKAGE_PATH}/${SERVICE_NAME}-stop.sh
|
||||
|
||||
systemctl enable ${SERVICE_NAME}
|
||||
systemctl start ${SERVICE_NAME}
|
||||
|
||||
echo "Register to auto start ... successed!"
|
||||
# startup
|
||||
echo "Start service ... successed!"
|
||||
# service ${SERVICE_NAME} restart
|
||||
|
||||
fi
|
||||
|
||||
# export version infomation
|
||||
echo "${1}" > .version
|
||||
echo "Done!"
|
||||
|
||||
popd > /dev/null
|
||||
73
archiso/airootfs/home/smart/SmartOrganizer/common/MiaozhenProbe/uninstall.sh
Executable file
73
archiso/airootfs/home/smart/SmartOrganizer/common/MiaozhenProbe/uninstall.sh
Executable file
@@ -0,0 +1,73 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 脚本所在目录 绝对路径
|
||||
ROOT_PATH="/home/smart/SmartOrganizer"
|
||||
. ${ROOT_PATH}/lib.conf
|
||||
|
||||
PACKAGE_PATH="/home/Miaozhen"
|
||||
PACKAGE_NAME="MiaozhenProbe"
|
||||
SERVICE_NAME="MiaozhenProbeService"
|
||||
|
||||
CURRENT_VERSION=""
|
||||
TARGET_VERSION="${1}"
|
||||
|
||||
if [[ -z ${TARGET_VERSION} ]]; then
|
||||
echo "Argument: TARGET_VERSION is needed!"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
|
||||
if [[ ! -d ${PACKAGE_PATH} ]]; then
|
||||
echo "Not installed ... uninstall stopped"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
pushd ${PACKAGE_PATH}
|
||||
|
||||
if [[ -f ".version" ]]; then
|
||||
CURRENT_VERSION="$(cat .version)"
|
||||
fi
|
||||
|
||||
if [[ -n ${CURRENT_VERSION} ]]; then
|
||||
echo "current_version:"${CURRENT_VERSION}" target_version:"${TARGET_VERSION}
|
||||
if [[ $(version_compare ${CURRENT_VERSION} ${TARGET_VERSION}) != -1 ]]; then
|
||||
echo "No upgrade required"
|
||||
popd > /dev/null
|
||||
exit 2
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $(getSystemVersion ) -eq 6 ]]; then
|
||||
# stop service
|
||||
service ${SERVICE_NAME} stop
|
||||
echo "Stop service ... successed!"
|
||||
|
||||
# stop auto startup
|
||||
chkconfig ${SERVICE_NAME} off
|
||||
chkconfig --del ${SERVICE_NAME}
|
||||
echo "Unregister from auto start ... successed!"
|
||||
|
||||
# remove files
|
||||
rm -f /etc/init.d/${SERVICE_NAME}
|
||||
echo "Unregister from system service ... successed!"
|
||||
else
|
||||
# stop service
|
||||
systemctl stop ${SERVICE_NAME}
|
||||
echo "Stop service ... successed!"
|
||||
|
||||
# stop auto startup
|
||||
systemctl disable ${SERVICE_NAME}
|
||||
echo "Unregister from auto start ... successed!"
|
||||
|
||||
# remove files
|
||||
rm -f /usr/lib/systemd/system/${SERVICE_NAME}.service
|
||||
echo "Unregister from system service ... successed!"
|
||||
fi
|
||||
|
||||
rm -rf ${PACKAGE_PATH}/*
|
||||
|
||||
echo "Delete source files (Except log files) ... successed!"
|
||||
|
||||
echo "Done!"
|
||||
|
||||
popd
|
||||
73
archiso/airootfs/home/smart/SmartOrganizer/common/SmartTMS_S3/rollback.sh
Executable file
73
archiso/airootfs/home/smart/SmartOrganizer/common/SmartTMS_S3/rollback.sh
Executable file
@@ -0,0 +1,73 @@
|
||||
#!/bin/bash
|
||||
|
||||
SO_PATH="/home/smart/SmartOrganizer"
|
||||
. ${SO_PATH}/lib.conf
|
||||
|
||||
SmartTMS_BASE_PATH="/home/smart/.tms3/repo"
|
||||
SmartTMS_CONFIG_FILE="${SmartTMS_BASE_PATH}/SmartTMS_Upgrade.conf"
|
||||
SmartTMS_VERSION_PATH="${SmartTMS_BASE_PATH}/versions"
|
||||
SmartTMS_BACKUP_PATH="${SmartTMS_BASE_PATH}/backup"
|
||||
|
||||
TARGET_VERSION=${1}
|
||||
DB_NAME="tms_db_s3"
|
||||
DB_PASSWORD="PythA90ra5"
|
||||
BACKUP_PATH="${SmartTMS_BACKUP_PATH}/${TARGET_VERSION}"
|
||||
TOMCAT_HOME="/home/smart/.tms3/apache-tomcat-*"
|
||||
|
||||
stop_tomcat()
|
||||
{
|
||||
pid=`netstat -lntp | grep :8080 | awk '{print $7}' |cut -d'/' -f1`
|
||||
if [[ ! -z ${pid} ]]; then
|
||||
kill ${pid}
|
||||
echo "TOMCAT Stopped!"
|
||||
fi
|
||||
}
|
||||
|
||||
start_tomcat()
|
||||
{
|
||||
sh ${TOMCAT_HOME}/bin/startup.sh
|
||||
# echo "TOMCAT Started!"
|
||||
}
|
||||
|
||||
rollback_db()
|
||||
{
|
||||
sqls=($(ls ${BACKUP_PATH} | grep .sql))
|
||||
num=${#sqls[@]}
|
||||
if [[ ${num} -gt 0 ]]; then
|
||||
sql=${sqls[num-1]}
|
||||
echo ">> Execute SQL ${TARGET_VERSION} ${BACKUP_PATH}/${sql}"
|
||||
mysql -uroot -p${DB_PASSWORD} ${DB_NAME} -f -s -N < ${BACKUP_PATH}/${sql}
|
||||
fi
|
||||
}
|
||||
|
||||
rollback_war()
|
||||
{
|
||||
rm -rf ${TOMCAT_HOME}/webapps/SmartTMS*
|
||||
echo "Remove current version"
|
||||
|
||||
cp ${BACKUP_PATH}/*.war ${TOMCAT_HOME}/webapps/
|
||||
echo "Copy backup version to web directory"
|
||||
}
|
||||
|
||||
if [[ -z ${TARGET_VERSION} ]]; then
|
||||
echo "Target version rollback to must be given!"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if [[ ! -d ${BACKUP_PATH} ]]; then
|
||||
echo "Backup version not exists. [ ${BACKUP_PATH} ], exit!"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
stop_tomcat
|
||||
sleep 10
|
||||
|
||||
rollback_db
|
||||
sleep 2
|
||||
|
||||
rollback_war
|
||||
sleep 4
|
||||
|
||||
start_tomcat
|
||||
|
||||
echo "Done!"
|
||||
142
archiso/airootfs/home/smart/SmartOrganizer/common/SmartTMS_S3/upgrade.sh
Executable file
142
archiso/airootfs/home/smart/SmartOrganizer/common/SmartTMS_S3/upgrade.sh
Executable file
@@ -0,0 +1,142 @@
|
||||
#!/bin/bash
|
||||
|
||||
SO_PATH="/home/smart/SmartOrganizer"
|
||||
. ${SO_PATH}/lib.conf
|
||||
|
||||
SmartTMS_BASE_PATH="/home/smart/.tms3/repo"
|
||||
SmartTMS_CONFIG_FILE="${SmartTMS_BASE_PATH}/SmartTMS_Upgrade.conf"
|
||||
SmartTMS_VERSION_PATH="${SmartTMS_BASE_PATH}/versions"
|
||||
SmartTMS_BACKUP_PATH="${SmartTMS_BASE_PATH}/backup"
|
||||
|
||||
CURRENT_VERSION=${1}
|
||||
TARGET_VERSION=${2}
|
||||
DB_NAME="tms_db_s3"
|
||||
DB_PASSWORD="PythA90ra5"
|
||||
VERSION_PATH="${SmartTMS_VERSION_PATH}/${TARGET_VERSION}"
|
||||
BACKUP_PATH="${SmartTMS_BACKUP_PATH}/${CURRENT_VERSION}"
|
||||
TOMCAT_HOME="/home/smart/.tms3/apache-tomcat-*"
|
||||
|
||||
stop_tomcat()
|
||||
{
|
||||
pid=`netstat -lntp | grep :8080 | awk '{print $7}' |cut -d'/' -f1`
|
||||
if [[ ! -z ${pid} ]]; then
|
||||
kill ${pid}
|
||||
echo "TOMCAT Stopped!"
|
||||
fi
|
||||
}
|
||||
|
||||
backup_db()
|
||||
{
|
||||
if [[ ! -d ${BACKUP_PATH} ]]; then
|
||||
mkdir -p ${BACKUP_PATH}
|
||||
fi
|
||||
BACKUP_SQL_FILE=${BACKUP_PATH}/${DB_NAME}"_"${CURRENT_VERSION}"_"`date -d today +"%Y%m%d%H%M"`.sql
|
||||
mysqldump -uroot -p${DB_PASSWORD} --default-character-set=utf8 ${DB_NAME} > ${BACKUP_SQL_FILE}
|
||||
echo "Backup database to [ ${BACKUP_SQL_FILE} ]"
|
||||
}
|
||||
|
||||
backup_war()
|
||||
{
|
||||
if [[ ! -d ${BACKUP_PATH} ]]; then
|
||||
mkdir -p ${BACKUP_PATH}
|
||||
fi
|
||||
\cp ${TOMCAT_HOME}/webapps/*.war ${BACKUP_PATH}/
|
||||
echo "Backup war ... completed!"
|
||||
rm -rf ${TOMCAT_HOME}/webapps/SmartTMS*
|
||||
echo "Remove old version"
|
||||
}
|
||||
|
||||
excute_sql()
|
||||
{
|
||||
sqls=$(ls ${VERSION_PATH}/sql)
|
||||
arr=($(get_version_range "${sqls}"))
|
||||
|
||||
for version in ${arr[@]}
|
||||
do
|
||||
sql=${VERSION_PATH}/sql/${version}/$(ls ${VERSION_PATH}/sql/${version} | grep sql)
|
||||
if [[ -f ${sql} ]]; then
|
||||
echo ">> Execute SQL ${version} ${sql}"
|
||||
mysql -uroot -p${DB_PASSWORD} ${DB_NAME} -f -s -N < ${sql}
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
get_version_range()
|
||||
{
|
||||
# filter
|
||||
source=($1)
|
||||
result=()
|
||||
for version in ${source[@]}; do
|
||||
if [[ `version_compare ${version} ${CURRENT_VERSION}` == 1 ]]; then
|
||||
result+=("${version}")
|
||||
fi
|
||||
done
|
||||
|
||||
# sort
|
||||
for (( i=0; i<${#result[@]}; i++ )); do
|
||||
for (( j=${#result[@]}-1; j>i; j-- )); do
|
||||
if [[ `version_compare ${result[j]} ${result[j-1]}` == -1 ]]; then
|
||||
t=${result[j]}
|
||||
result[j]=${result[j-1]}
|
||||
result[j-1]=${t}
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
echo ${result[@]}
|
||||
}
|
||||
|
||||
update_war()
|
||||
{
|
||||
cp ${VERSION_PATH}/*.war ${TOMCAT_HOME}/webapps/
|
||||
echo "Copy new version to web directory"
|
||||
}
|
||||
|
||||
start_tomcat()
|
||||
{
|
||||
sh ${TOMCAT_HOME}/bin/startup.sh
|
||||
# echo "TOMCAT Started!"
|
||||
}
|
||||
|
||||
if [[ -z ${CURRENT_VERSION} || -z ${TARGET_VERSION} ]]; then
|
||||
echo "Usage: CURRENT_VERSION and TARGET_VERSION is necessary!"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if [[ $(version_compare ${CURRENT_VERSION} ${TARGET_VERSION}) != -1 ]]; then
|
||||
echo "No upgrade required!"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if [[ ! -f ${VERSION_PATH}/SmartTMS_S3.war ]]; then
|
||||
rm -rf ${VERSION_PATH}
|
||||
echo "Has some problem of package file! EXIT!"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
#version_compare 3.0.12 3.1.12
|
||||
|
||||
#kill tomcat
|
||||
stop_tomcat
|
||||
sleep 10
|
||||
|
||||
#back db
|
||||
backup_db
|
||||
sleep 2
|
||||
|
||||
#excute sql file
|
||||
excute_sql
|
||||
sleep 2
|
||||
|
||||
#back war
|
||||
backup_war
|
||||
sleep 2
|
||||
|
||||
#update war
|
||||
update_war
|
||||
sleep 4
|
||||
|
||||
#start tomcat
|
||||
start_tomcat
|
||||
|
||||
echo "Done!"
|
||||
263
archiso/airootfs/home/smart/SmartOrganizer/common/SunloginClient/install.sh
Executable file
263
archiso/airootfs/home/smart/SmartOrganizer/common/SunloginClient/install.sh
Executable file
@@ -0,0 +1,263 @@
|
||||
#!/bin/bash
|
||||
|
||||
install_path="/opt/sunlogin"
|
||||
|
||||
ROOT_PATH=$(cd "$(dirname ${0})";pwd)
|
||||
|
||||
echo "Sunlogin client for linux installer by oray.com"
|
||||
echo "-------------------------------"
|
||||
|
||||
#read -p "Install sunlogin client to your system?(Y/n)" willinstall
|
||||
#if [ -z $willinstall ]; then
|
||||
# willinstall='Y'
|
||||
#fi
|
||||
#if [ $willinstall != 'Y' ] && [ $willinstall != 'y' ]; then
|
||||
# echo $willinstall
|
||||
# exit
|
||||
#fi
|
||||
|
||||
#change directory to script path
|
||||
curpath=$(cd "$(dirname "$0")"; pwd)
|
||||
cd $curpath > /dev/null
|
||||
|
||||
source ./scripts/common.sh
|
||||
|
||||
#check root
|
||||
check_root
|
||||
|
||||
|
||||
source ./scripts/depends.sh
|
||||
|
||||
echo "Checking system dependencies...."
|
||||
if [ -z "$depends" ]; then
|
||||
echo "OK."
|
||||
else
|
||||
echo "Sunlogin requires following components to be installed to your system:"
|
||||
echo $packet
|
||||
echo "-------------------------------"
|
||||
# read -p "Install all dependencies automatically(Y/n)" install
|
||||
# if [ -z $install ]; then
|
||||
# install='Y'
|
||||
# fi
|
||||
# if [ $install != 'Y' ] && [ $install != 'Y' ]; then
|
||||
# echo "Please install the missing components manualy"
|
||||
# exit
|
||||
# else
|
||||
yum install -y $packet
|
||||
# fi
|
||||
fi
|
||||
|
||||
#kill all runing sunloginclient_linux
|
||||
killall sunloginclient_linux
|
||||
|
||||
|
||||
function old_version_lightdm_init_create
|
||||
{
|
||||
src_str='\[SeatDefaults\]'
|
||||
dest_str='greeter-setup-script=xhost +'
|
||||
file_name='/etc/lightdm/lightdm.conf'
|
||||
tmp_file_name='/tmp/lightdm.conf.tmp'
|
||||
|
||||
if [ ! -f $file_name ]; then
|
||||
echo "no $file_name file"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ $(grep "'$dest_str'" $file_name) ]; then
|
||||
echo 'already replace'
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ $(grep "$src_str" $file_name) ]; then
|
||||
sed "s/$src_str/$src_str\n$dest_str/" $file_name > $tmp_file_name
|
||||
cp $tmp_file_name $file_name
|
||||
rm $tmp_file_name
|
||||
return 0
|
||||
else
|
||||
echo "has no [$src_str]"
|
||||
return 1
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
function gdm_init_create
|
||||
{
|
||||
dest_str='xhost +'
|
||||
file_name='/etc/gdm/Init/Default'
|
||||
|
||||
if [ ! -f $file_name ]; then
|
||||
echo "no $file_name file"
|
||||
return 1
|
||||
fi
|
||||
|
||||
result=$(grep "$dest_str" "$file_name")
|
||||
if [ ! "$result" == '' ]; then
|
||||
echo 'already replace'
|
||||
return 0
|
||||
fi
|
||||
|
||||
sed "2 i$dest_str" -i $file_name
|
||||
|
||||
return 0
|
||||
|
||||
}
|
||||
|
||||
if [ $os_name == 'ubuntu' ] || [ $os_name == 'deepin' ] || [ $os_name == 'centos' ] || [ $(echo $os_name |grep redhat) != "" ]; then
|
||||
echo 'check operate system OK'
|
||||
else
|
||||
echoAndExit 'unknown OS it not impl'
|
||||
fi
|
||||
|
||||
|
||||
mkdir $path_bin -p || echoAndExit "create bin directory failed : $path_bin"
|
||||
echo "copy oray_rundaemon to $path_bin"
|
||||
cp ./bin/$os_bits/oray_rundaemon $path_bin/oray_rundaemon || echoAndExit 'can not copy oray_rundaemon file'
|
||||
echo "copy sunloginclient_linux to $path_bin"
|
||||
cp ./bin/$os_bits/sunloginclient_linux $path_bin || echoAndExit 'can not copy sunloginclient_linux file'
|
||||
echo "copy ethtool to $path_bin"
|
||||
cp ./bin/$os_bits/ethtool $path_bin || echoAndExit 'can not copy ethtool file'
|
||||
echo "copy accpet.sh to $path_bin"
|
||||
cp ./scripts/accpet.sh $path_bin || echoAndExit 'can not copy accpet.sh file'
|
||||
chmod +x $path_bin/*.sh
|
||||
os_version_int=${os_version%.*}
|
||||
for i in $(seq 1 10)
|
||||
do
|
||||
os_version_int=${os_version_int%.*}
|
||||
done
|
||||
|
||||
|
||||
mkdir $path_etc -p || echoAndExit "create etc directory failed : $path_etc"
|
||||
echo "copy watch.sh to $path_etc"
|
||||
cp ./scripts/watch.sh $path_etc || echoAndExit 'can not copy runsunlogin.sh file'
|
||||
chmod +x $path_etc/watch.sh
|
||||
|
||||
echo "copy start.sh to $path_main"
|
||||
cp ./scripts/start.sh $path_main/
|
||||
echo "copy common.sh to $path_main"
|
||||
cp ./scripts/common.sh $path_main/
|
||||
echo "copy stop.sh to $path_main"
|
||||
cp ./scripts/stop.sh $path_main/
|
||||
echo "copy uninstall.sh to $path_main"
|
||||
cp ./scripts/uninstall.sh $path_main/
|
||||
#echo "copy install.sh to $path_main"
|
||||
#cp ./install.sh $path_main/
|
||||
chmod +x $path_main/*.sh
|
||||
chmod +x ./install.sh
|
||||
|
||||
cp README $path_main/
|
||||
|
||||
#echo "create init"
|
||||
if [ $os_name == 'ubuntu' ]; then
|
||||
cp ./scripts/lightdm.conf /usr/share/lightdm/lightdm.conf.d/50-slscreenagrentsvr.conf > /dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo 'no pos /usr/share/lightdm, so modify base lightdm.conf file'
|
||||
old_version_lightdm_init_create
|
||||
if [ $? -ne 0 ]; then
|
||||
echo 'no lightdm.conf file, so use gdm'
|
||||
gdm_init_create
|
||||
if [ $? -ne 0 ]; then
|
||||
echoAndExit 'create lightdm init failed'
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if [ $os_version_int -lt 15 ]; then
|
||||
cp ./scripts/runsunloginclient.conf /etc/init/runsunloginclient.conf || echoAndExit 'can not copy init file runsunloginclient.conf'
|
||||
else
|
||||
cp ./scripts/runsunloginclient.service /etc/systemd/system/runsunloginclient.service || echoAndExit 'can not copy init file runsunloginclient.service'
|
||||
systemctl enable runsunloginclient.service
|
||||
fi
|
||||
|
||||
cd - > /dev/null
|
||||
|
||||
elif [ $os_name == 'deepin' ]; then
|
||||
cp ./scripts/lightdm.conf /usr/share/lightdm/lightdm.conf.d/50-slscreenagrentsvr.conf > /dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo 'no pos /usr/share/lightdm, so modify base lightdm.conf file'
|
||||
old_version_lightdm_init_create
|
||||
if [ $? -ne 0 ]; then
|
||||
echo 'no lightdm.conf file, so use gdm'
|
||||
gdm_init_create
|
||||
if [ $? -ne 0 ]; then
|
||||
echoAndExit 'create lightdm init failed'
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if [ $os_version_int -gt 2000 ]; then
|
||||
let os_version_int=os_version_int-2000
|
||||
fi
|
||||
if [ $os_version_int -lt 15 ]; then
|
||||
cp ./scripts/runsunloginclient.conf /etc/init/runsunloginclient.conf || echoAndExit 'can not copy init file runsunloginclient.conf'
|
||||
else
|
||||
cp ./scripts/runsunloginclient.service /etc/systemd/system/runsunloginclient.service || echoAndExit 'can not copy init file runsunloginclient.service'
|
||||
systemctl enable runsunloginclient.service
|
||||
fi
|
||||
|
||||
cd - > /dev/null
|
||||
|
||||
|
||||
elif [ "$os_name" == "centos" ] || [ $(echo $os_name |grep redhat) != "" ] ; then
|
||||
gdm_init_create
|
||||
if [ $os_version_int -lt 7 ]; then
|
||||
echo "copy init_runsunloginclient to /etc/init.d/"
|
||||
cp ./scripts/init_runsunloginclient /etc/init.d/runsunloginclient || echoAndExit 'can not copy init file init_runsunloginclient'
|
||||
chmod +x /etc/init.d/runsunloginclient
|
||||
#create soft link
|
||||
for i in $(seq 0 6)
|
||||
do
|
||||
ln -s /etc/init.d/runsunloginclient /etc/rc$i.d/S99runsunloginclient > /dev/null 2>&1
|
||||
done
|
||||
/sbin/chkconfig --add runsunloginclient
|
||||
/sbin/chkconfig runsunloginclient on
|
||||
else
|
||||
echo "copy runsunloginclient.service to /etc/systemd/system/"
|
||||
cp ./scripts/runsunloginclient.service /etc/systemd/system/runsunloginclient.service || echoAndExit 'can not copy init file runsunloginclient.service'
|
||||
systemctl enable runsunloginclient.service
|
||||
fi
|
||||
|
||||
#echo "Sunlogin client installed in $path_main Enjoy!"
|
||||
cd - > /dev/null
|
||||
|
||||
#echo "get gdm X Authority"
|
||||
#xhost + >/dev/null 2>&1 || /usr/sbin/gdm-restart
|
||||
else
|
||||
|
||||
echo 'unknown OS is not impl'
|
||||
fi
|
||||
|
||||
#read -p "Start sunlogin now(Y/n)" startnow
|
||||
#if [ -z $startnow ]; then
|
||||
# startnow='Y'
|
||||
#fi
|
||||
#if [ $startnow == 'Y' ] || [ $startnow == 'y' ]; then
|
||||
/usr/local/sunlogin/start.sh
|
||||
# read -p "Configure your sunlogin client now(Y/n)" confignow
|
||||
# if [ -z $confignow ]; then
|
||||
# confignow='Y'
|
||||
# fi
|
||||
# if [ $confignow != 'Y' ] && [ $confignow != 'y' ]; then
|
||||
# echo "use your browser to config or run '/usr/local/sunlogin/bin/sunloginclient_linux --mod=shell' to config interactively."
|
||||
# else
|
||||
# /usr/local/sunlogin/bin/sunloginclient_linux --mod=shell
|
||||
# fi
|
||||
#fi
|
||||
|
||||
echo "Successfully installed Sunlogin client ver 9.6"
|
||||
echo "-------------------------------"
|
||||
echo "Start: /usr/local/sunlogin/start.sh"
|
||||
echo "Stop: /usr/local/sunlogin/stop.sh"
|
||||
echo "Uninstall: /usr/local/sunlogin/uninstall.sh"
|
||||
echo "-------------------------------"
|
||||
echo "Configure(via shell): /usr/local/sunlogin/bin/sunloginclient_linux --mod=shell"
|
||||
echo "Configure(via browser): Please visit <this machine ip>:30080"
|
||||
echo "-------------------------------"
|
||||
echo "Safety note: Block 30080/tcp after configuration."
|
||||
echo "-------------------------------"
|
||||
echo "Note:"
|
||||
echo "Sunlogin remote desktop for linux needs "lightdm" to be installed, otherwise functions like "SSH, RemoteFile" will still work,if it don't work, you need install the package manually."
|
||||
echo "Step"
|
||||
echo "1. apt-get install lightdm"
|
||||
echo "2. click OK on the pop dialog, select "lightdm" as your default display manager"
|
||||
echo "-------------------------------"
|
||||
echo "Enjoy."
|
||||
|
||||
|
||||
171
archiso/airootfs/home/smart/SmartOrganizer/common/SunloginClient/upgrade.sh
Executable file
171
archiso/airootfs/home/smart/SmartOrganizer/common/SunloginClient/upgrade.sh
Executable file
@@ -0,0 +1,171 @@
|
||||
#!/bin/bash
|
||||
|
||||
ROOT_PATH=$(cd "$(dirname ${0})";pwd)
|
||||
CFG_VERSION=${1}
|
||||
|
||||
if [[ ! -n ${CFG_VERSION} ]]; then
|
||||
CFG_VERSION="9.6.1"
|
||||
fi
|
||||
|
||||
#discription:SunloginClient9.6.1
|
||||
install_path="/opt/sunlogin"
|
||||
script_path="${install_path}/sunloginclient/scripts"
|
||||
version="SunloginClient9.6.1"
|
||||
download_url="http://download.oray.com/sunlogin/linux/${version}.tar.gz"
|
||||
desktop_restart_service="/usr/share/applications/sunlogin-restart.desktop"
|
||||
desktop_stop_service="/usr/share/applications/sunlogin-stop.desktop"
|
||||
user_name="smart"
|
||||
user_home_path="/home/smart/桌面/"
|
||||
|
||||
#color
|
||||
red='\033[0;31m'
|
||||
green='\033[0;32m'
|
||||
yellow='\033[0;33m'
|
||||
plain='\033[0m'
|
||||
|
||||
#安装目录
|
||||
create_documoent(){
|
||||
mkdir $install_path
|
||||
cd $install_path
|
||||
}
|
||||
|
||||
#下载文件
|
||||
function download_file(){
|
||||
wget $download_url
|
||||
tar -zxf ./${version}.tar.gz
|
||||
cd ${install_path}/sunloginclient
|
||||
echo "Download is ok!"
|
||||
}
|
||||
|
||||
#桌面快捷方式
|
||||
function desktop_file(){
|
||||
touch ${desktop_restart_service}
|
||||
chmod 777 ${desktop_restart_service}
|
||||
cat > "${desktop_restart_service}" <<EOF
|
||||
#!/usr/bin/env xdg-open
|
||||
[Desktop Entry]
|
||||
Name=sunlogin_restart
|
||||
Name[zh_CN]=向日葵重启
|
||||
Comment= run sunlogin
|
||||
Exec=${script_path}/sudo_restart.sh
|
||||
Terminal=true
|
||||
Type=Application
|
||||
EOF
|
||||
ln -s ${desktop_restart_service} ${user_home_path}
|
||||
}
|
||||
|
||||
function stop_service_file(){
|
||||
touch ${desktop_stop_service}
|
||||
chmod 777 ${desktop_stop_service}
|
||||
cat > "${desktop_stop_service}" <<EOF
|
||||
#!/usr/bin/env xdg-open
|
||||
[Desktop Entry]
|
||||
Name=sunlogin_stop
|
||||
Name[zh_CN]=向日葵停止
|
||||
Comment= run sunlogin
|
||||
Exec=${script_path}/sudo_stop.sh
|
||||
Terminal=true
|
||||
Type=Application
|
||||
EOF
|
||||
ln -s ${desktop_stop_service} ${user_home_path}
|
||||
}
|
||||
|
||||
#重启文件
|
||||
function sudo_restart_file(){
|
||||
cd ${script_path}
|
||||
touch sudo_restart.sh
|
||||
chmod 777 sudo_restart.sh
|
||||
cat > "sudo_restart.sh" <<EOF
|
||||
#!/bin/bash
|
||||
sudo sh ${script_path}/stop.sh
|
||||
sudo sh ${script_path}/start.sh
|
||||
EOF
|
||||
}
|
||||
|
||||
#停止文件
|
||||
function sudo_stop_file(){
|
||||
cd ${script_path}
|
||||
touch sudo_stop.sh
|
||||
chmod 777 sudo_stop.sh
|
||||
cat > "sudo_stop.sh" <<EOF
|
||||
#!/bin/bash
|
||||
sudo sh ${script_path}/stop.sh
|
||||
EOF
|
||||
}
|
||||
|
||||
|
||||
#安装
|
||||
function install_script(){
|
||||
if [[ -d ${install_path} ]]
|
||||
then
|
||||
echo "${install_path} is existed, please uninstall!"
|
||||
exit 1
|
||||
else
|
||||
sed -i "2a $user_name ALL=(root) NOPASSWD:/bin/sh" /etc/sudoers
|
||||
create_documoent
|
||||
download_file
|
||||
\cp ${ROOT_PATH}/install.sh ${install_path}/sunloginclient/install.sh
|
||||
sudo_restart_file
|
||||
sudo_stop_file
|
||||
desktop_file
|
||||
stop_service_file
|
||||
sh ${install_path}/sunloginclient/install.sh
|
||||
writeSunVersion
|
||||
reportConnectionCodes
|
||||
echo "================================================================="
|
||||
echo "Please visit http://<this machine ip>:30080 to configure remote client!"
|
||||
echo "================================================================="
|
||||
fi
|
||||
}
|
||||
|
||||
#卸载
|
||||
function uninstall(){
|
||||
if [[ -d ${install_path} ]]
|
||||
then
|
||||
echo "${install_path} is existed"
|
||||
sh ${script_path}/uninstall.sh
|
||||
sed -i '3d' /etc/sudoers
|
||||
rm -rf ${install_path}
|
||||
rm -f ${desktop_restart_service}
|
||||
rm -f ${desktop_stop_service}
|
||||
rm -f ${user_home_path}/sunlogin-restart.desktop
|
||||
rm -f ${user_home_path}/sunlogin-stop.desktop
|
||||
echo "Uninstall is ok!"
|
||||
else
|
||||
echo "${install_path} is not exist"
|
||||
fi
|
||||
}
|
||||
|
||||
#重新安装
|
||||
function reinstall(){
|
||||
uninstall
|
||||
install_script
|
||||
}
|
||||
|
||||
#上报访问信息
|
||||
reportConnectionCodes()
|
||||
{
|
||||
#尝试6次
|
||||
try=6
|
||||
while [[ ${try} -ge 0 ]]; do
|
||||
sleep 10
|
||||
REPORT=$(curl -sS http://localhost:30080 | grep 'Quick Code')
|
||||
if [[ -n ${REPORT} ]]; then
|
||||
quick_code=$(echo ${REPORT} | awk -F ': ' '{print $2}' | awk -F '<' '{print $1}')
|
||||
security_code=$(echo ${REPORT} | awk -F ': ' '{print $3}' | awk -F '<' '{print $1}')
|
||||
hostname=$(hostname)
|
||||
echo "Follow up writing: quick_code is ${quick_code},security_code is ${security_code}"
|
||||
# 回访写入
|
||||
curl -sS -D /dev/null -o /dev/null -H "hostname:${hostname}" "http://c.baobaot.com/api/software/report_sunlogin_codes?quick_code=${quick_code}&security_code=${security_code}"
|
||||
break
|
||||
fi
|
||||
try=$[${try} - 1]
|
||||
done
|
||||
}
|
||||
|
||||
writeSunVersion()
|
||||
{
|
||||
echo ${CFG_VERSION} > ${install_path}/.version
|
||||
}
|
||||
|
||||
reinstall
|
||||
Reference in New Issue
Block a user