Chinaunix首页 | 论坛 | 博客
  • 博客访问: 803239
  • 博文数量: 274
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 862
  • 用 户 组: 普通用户
  • 注册时间: 2015-10-24 15:31
个人简介

不合格的程序猿

文章分类

全部博文(274)

文章存档

2019年(3)

2018年(1)

2017年(4)

2016年(160)

2015年(106)

我的朋友

分类: 系统运维

2016-03-07 20:49:35

修改ngtos脚本文件


点击(此处)折叠或打开

  1. #!/bin/bash

  2. NGTOS_FILE="/tos/bin/ngtos"
  3. if [ $# -gt 1 ];then
  4.     exit 1
  5. elif [ $# -eq 1 ] && [ $1 = "package" ]; then
  6.     NGTOS_FILE="/home/ngos/workspace/ngtos-package/tos-addon//tos/bin/ngtos"
  7. fi

  8. NULL="/dev/null"

  9. INSTALL_OPENLDAP="sh /tos/bin/openldap_start install"
  10. START_OPENLDAP="sh /tos/bin/openldap_start start"
  11. STOP_OPENLDAP="sh /tos/bin/openldap_start stop"
  12. START_SSLVPN="sh /tos/bin/sslvpn start"
  13. STOP_SSLVPN="sh /tos/bin/sslvpn stop"

  14. STR_LIBRARY_PATH="export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:/tmp/ldap_tos/BerkeleyDB/lib:/tmp/ldap_tos/openssl/lib:/tmp/ldap_tos/openldap/lib"
  15. STR_PATH="export PATH=\$PATH:/tmp/ldap_tos/BerkeleyDB/bin:/tmp/ldap_tos/openssl/bin:/tmp/ldap_tos/openldap/bin:/tmp/ldap_tos/openldap/sbin"

  16. if [ ! -f $NGTOS_FILE ]; then
  17.     exit 1
  18. fi

  19. #add environment variable of openldap to ngtos
  20. grep "/tmp/ldap_tos/openssl/lib" $NGTOS_FILE > $NULL
  21. if [ $? -ne 0 ]; then
  22.     sed -i "/export USE_TOS_MTRACK=no/a\\\\n${STR_LIBRARY_PATH}\n${STR_PATH}\n" $NGTOS_FILE
  23. fi

  24. #add "openldap_start start" to ngtos
  25. grep "openldap_start start" $NGTOS_FILE > $NULL
  26. if [ $? -ne 0 ]; then
  27.     sed -i "/ngtos start/a\ \n\t#install openldap\n\t${INSTALL_OPENLDAP}\n\t#start openldap\n\t${START_OPENLDAP}\n" $NGTOS_FILE
  28. fi

  29. #add "sslvpn start" to ngtos
  30. grep "${START_SSLVPN}" $NGTOS_FILE > $NULL
  31. if [ $? -ne 0 ]; then
  32.     sed -i "/\/tos\/bin\/tp_agent/a\ \n\t#start sslvpn\n\t${START_SSLVPN}\n" $NGTOS_FILE
  33. fi


  34. unset END_LINE
  35. eval $(awk '{
  36.     RET=index($0, "ngtos stop");
  37.     if (RET > 0)
  38.     {
  39.         START_FLAG = 1;
  40.         END_FLAG = 1;
  41.     }

  42.     RET = index($0, "{");
  43.     if (RET > 0)
  44.     {
  45.         END_FLAG += 1;
  46.     }

  47.     RET = index($0, "}");
  48.     if (RET > 0)
  49.     {
  50.         END_FLAG -= 1;
  51.     }


  52.     if (1 == START_FLAG && 0 == END_FLAG)
  53.     {
  54.         RET = index($0, "}");
  55.         if (RET > 0)
  56.         {
  57.             END_FLAG = 1;
  58.             START_FLAG = 0;
  59.             print "END_LINE="NR
  60.         }
  61.     }
  62. }' $NGTOS_FILE)

  63. #add "sslvpn stop" and "openldap stop" to ngtos
  64. grep "stop sslvpn" $NGTOS_FILE > $NULL
  65. if [ $? -ne 0 ]; then
  66.     sed -i "$END_LINE i \\\n\t#stop sslvpn\n\t${STOP_SSLVPN}\n\n\t#stop openldap\n\t${STOP_OPENLDAP}" $NGTOS_FILE
  67. fi

阅读(862) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~