#!/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}" < "${desktop_stop_service}" < "sudo_restart.sh" < "sudo_stop.sh" <: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