From 02d67cf57b11fde280c44da3a67ea76a56fb2c98 Mon Sep 17 00:00:00 2001 From: LI JIAHAO Date: Wed, 8 Feb 2017 12:55:07 +0800 Subject: [PATCH] 2.3 --- README.md | 8 ++-- install.sh | 123 ++++++++++++++++++++++++++++++++++++++------------- ipgw.sh | 5 ++- uninstall.sh | 38 ++++++++++++++++ 4 files changed, 139 insertions(+), 35 deletions(-) create mode 100644 uninstall.sh diff --git a/README.md b/README.md index c5e83f9..7ede79a 100644 --- a/README.md +++ b/README.md @@ -14,15 +14,17 @@ Find [[Wiki]](https://github.com/2645Corp/neu-ipgw_linux/wiki) if you need. open terminal and run -`$ sudo sh ./install.sh` +`$ sh ./install.sh` + +The program will require sudo password. After running the installer, you may either start from the "Application Menu", or run by command `ipgw`.
Use `ipgw --help` to get more information of usage.
-**For version v2.2 and later** +**For version v2.3 and later** The program will be installed to `/opt/2645/neuipgw/`
-You may change the configuration of the installed program by editing `/etc/neuipgw/user.cfg` +You may change the configuration of the installed program by editing `~/.neuipgw/user.cfg` **For version v2.1 and before** diff --git a/install.sh b/install.sh index b2e25a2..9ba6cad 100644 --- a/install.sh +++ b/install.sh @@ -7,47 +7,108 @@ ######################################################################### #!/bin/bash -echo "欢迎使用neu ipgw登陆器 2645工作室出品" -echo "请输入校园网账号:" +echo "Would you like a Chinese installation prompt?(y/N)" +read zh_enable +if [[ $zh_enable == 'y' ]] || [[ $zh_enable == 'Y' ]]; then + echo "欢迎使用NEU IPGW登陆器 2645工作室出品" +else + echo "Thanks for using NEU-IPGW, made by 2645 Studio" +fi + +me=`whoami` + +if [[ $me == "root" ]]; +then + if [[ $zh_enable == 'y' ]] || [[ $zh_enable == 'Y' ]]; then + echo "警告:您正在以超级管理员身份安装,您确定这是您想做的吗?" + else + echo "Warning: You're running as root, are you sure it's what you want to do?" + fi +fi + +if [[ $zh_enable == 'y' ]] || [[ $zh_enable == 'Y' ]]; then + echo "您想要为所有用户安装(Y)还是为当前用户安装(n)?" +else + echo "Would you like to install for all users(Y) or for current user only(n)?" +fi +read ins4all + +if [[ $zh_enable == 'y' ]] || [[ $zh_enable == 'Y' ]]; then + echo "请输入校园网账号:" +else + echo "Please enter your campus network username:" +fi read username -echo "请输入校园网密码:" +if [[ $zh_enable == 'y' ]] || [[ $zh_enable == 'Y' ]]; then + echo "请输入校园网密码:" +else + echo "Please enter your password:" +fi stty -echo read password -echo "请再次输入校园网密码:" +if [[ $zh_enable == 'y' ]] || [[ $zh_enable == 'Y' ]]; then + echo "请再次输入校园网密码:" +else + echo "Please confirm your password:" +fi read repassword -while [ $password != $repassword ]; +while [[ $password != $repassword ]]; do -echo "两次输入的密码不一致,请重试!" -echo "请输入校园网密码:" +if [[ $zh_enable == 'y' ]] || [[ $zh_enable == 'Y' ]]; then + echo "两次输入的密码不一致,请重试!" + echo "请输入校园网密码:" +else + echo "Password inputted mismatch, please retry!" + echo "Please enter your password:" +fi read password -echo "请再次输入校园网密码:" +if [[ $zh_enable == 'y' ]] || [[ $zh_enable == 'Y' ]]; then + echo "请再次输入校园网密码:" +else + echo "Please confirm your password:" +fi read repassword done stty echo -mkdir /opt/2645 -mkdir /opt/2645/neuipgw -mkdir /etc/neuipgw -cp ./ipgw.sh /opt/2645/neuipgw/ipgw -chmod 755 /opt/2645/neuipgw/ipgw -#cp ./user.cfg /usr/local/neuipgw/user.cfg -echo "#!/bin/bash" > /etc/neuipgw/user.cfg -echo "USER_NAME=$username" >> /etc/neuipgw/user.cfg -echo "USER_PASS=$password" >> /etc/neuipgw/user.cfg -cp ./ipgw.png /opt/2645/neuipgw/ipgw.png -rm -f /usr/bin/ipgw -ln -s /opt/2645/neuipgw/ipgw /usr/bin/ipgw - -echo [Desktop Entry]>/usr/share/applications/neuipgw.desktop -echo Name=NEU-IPGW>>/usr/share/applications/neuipgw.desktop -echo Comment=Speedier Internet Access>>/usr/share/applications/neuipgw.desktop -echo Exec=/usr/bin/ipgw>>/usr/share/applications/neuipgw.desktop -echo Icon=/opt/2645/neuipgw/ipgw.png>>/usr/share/applications/neuipgw.desktop -echo Terminal=true>>/usr/share/applications/neuipgw.desktop -echo Type=Application>>/usr/share/applications/neuipgw.desktop -echo Categories=Network>>/usr/share/applications/neuipgw.desktop - -echo "安装成功!" +sudo mkdir -p /opt/2645 +sudo mkdir -p /opt/2645/neuipgw +mkdir -p /home/$me/.neuipgw +if [[ $ins4all != 'n' ]] && [[ $ins4all != 'N' ]]; +then + sudo mkdir -p /usr/share/applications + desktop_path="/usr/share/applications/neuipgw.desktop" +else + mkdir -p /home/$me/.local/share/applications + desktop_path="/home/$me/.local/share/applications/neuipgw.desktop" +fi + +sudo cp ./ipgw.sh /opt/2645/neuipgw/ipgw +sudo cp ./install.sh /opt/2645/neuipgw/install.sh +sudo cp ./uninstall.sh /opt/2645/neuipgw/uninstall.sh +sudo chmod 755 /opt/2645/neuipgw/ipgw + +echo "#!/bin/bash" > /home/$me/.neuipgw/user.cfg +echo "USER_NAME=$username" >> /home/$me/.neuipgw/user.cfg +echo "USER_PASS=$password" >> /home/$me/.neuipgw/user.cfg +sudo cp ./ipgw.png /opt/2645/neuipgw/ipgw.png +sudo rm -f /usr/bin/ipgw +sudo ln -s /opt/2645/neuipgw/ipgw /usr/bin/ipgw + +sudo sh -c "echo [Desktop Entry]>$desktop_path" +sudo sh -c " echo Name=NEU-IPGW>>$desktop_path" +sudo sh -c "echo Comment=Speedier Internet Access>>$desktop_path" +sudo sh -c " echo Exec=/usr/bin/ipgw>>$desktop_path" +sudo sh -c " echo Icon=/opt/2645/neuipgw/ipgw.png>>$desktop_path" +sudo sh -c " echo Terminal=true>>$desktop_path" +sudo sh -c " echo Type=Application>>$desktop_path" +sudo sh -c " echo Categories=Network>>$desktop_path" + +if [[ $zh_enable == 'y' ]] || [[ $zh_enable == 'Y' ]]; then + echo "安装成功!" +else + echo "Complete!" +fi diff --git a/ipgw.sh b/ipgw.sh index a680dbb..dc45ed1 100644 --- a/ipgw.sh +++ b/ipgw.sh @@ -121,8 +121,11 @@ DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" if [ -f "$DIR/user.cfg" ]; then source $DIR/user.cfg +elif [ -f "/home/`whoami`/.neuipgw/user.cfg" ]; then + source /home/`whoami`/.neuipgw/user.cfg else - source /etc/neuipgw/user.cfg + echo "No config file found for current user,please specify username! See ipgw --help" + echo -e "You can generate a config file by running the installer with command\n\n sh $DIR/install.sh\n" fi temp=$(getopt -q -o qcdfmu:p:h --long connect,disconnect,force,mobile,query,username:,password:,help -- "$@") diff --git a/uninstall.sh b/uninstall.sh new file mode 100644 index 0000000..38714fc --- /dev/null +++ b/uninstall.sh @@ -0,0 +1,38 @@ +######################################################################### +# File Name: uninstall.sh +# Author: Li Jiahao +# ############### +# mail: lijiahao@cool2645.com +# Created Time: Wed 08 Feb 2017 11:49:25 AM CST +######################################################################### +#!/bin/bash + +echo "感谢使用NEU IPGW登陆器 2645工作室出品" + +echo "您确定要卸载吗(Y/n)?这将会删除程序安装目录内的所有文件。" +read confirm + +if [[ $confirm == 'n' ]] || [[ $confirm == 'N' ]] ; +then + exit +fi + +me=`whoami` + +sudo rm -rf /opt/2645/neuipgw +sudo rm -rf /usr/local/neuipgw #old version +sudo rm -rf /usr/bin/ipgw +sudo rm -f /usr/share/applications/neuipgw.desktop +rm -f /home/$me/.local/share/applications/neuipgw.desktop +sudo rm -rf /etc/neuipgw #old version + +echo "是否清除密码等配置信息(y/N)?此操作将不会影响你电脑上的其他用户。" +read clconfig + +if [[ $clconfig == 'y' ]] || [[ $clconfig == 'Y' ]] ; +then + rm -rf /home/$me/.neuipgw +fi + + +echo "卸载成功!"