Bo's Oracle Station

查看: 2022|回复: 0

(52-17)第29/30次:2015-12-8星期二和2015-12-10星期四

[复制链接]

75

主题

115

帖子

2724

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
2724
发表于 2015-12-12 23:03:11 | 显示全部楼层 |阅读模式
52章上完第17章:1Z0-053的19章。

bmf:
  1. #!/bin/sh
  2. sub_confirm() {
  3.         #
  4.         # Sub_answer begin:
  5.         #
  6.         # Written by a RHCE, Tang Bo. Report Bugs to "tangbo@fjirsm.ac.cn".
  7.         # Version 1.1.1. Last modified on Jan 13rd 2007:
  8.         # 1.0   Original
  9.         # 1.1   Introduce "sub_sub_answer()"
  10.         # 1.1.1 "BFS1(Bash Format Standard V1)" applied
  11.         sub_answer() {
  12.                 unset SUBANS
  13.                 #
  14.                 # Sub_sub_answer begin:
  15.                 #
  16.                 # Written by a RHCE, Tang Bo. Report Bugs to "tangbo@fjirsm.ac.cn".
  17.                 # Version 1.0. Last modified on Jan 13rd 2007:
  18.                 # 1.0   Original
  19.                 sub_sub_answer(){
  20.                         SUBANS=`echo $SUBANS |tr -d "[:blank:]"`
  21.                         if [ -z $SUBANS ]
  22.                         then
  23.                         SUBANS="NULL"
  24.                         fi
  25.                 }
  26.                 #
  27.                 # Sub_sub_answer end.
  28.                 #
  29.                 read -p "$1" SUBANS
  30.                 sub_sub_answer # Line15
  31.                 # Line15 begin: Deal with $SUNANS:
  32.                 until [ $SUBANS ==  "y"  -o  $SUBANS ==  "n" ]
  33.                 do
  34.                         echo "This question should be answered either with "y" or "n"."
  35.                         read -p "$1" SUBANS
  36.                         sub_sub_answer
  37.                 done
  38.                 # Line15 end.
  39.         }
  40.         #
  41.         # Sub_answer end.
  42.         #
  43.         unset SUBCON1
  44.         unset SUBCON2
  45.         SUBCON1=0
  46.         SUBCON2=1
  47.         until [ $SUBCON1 == $SUBCON2 ]
  48.         do
  49.                 read -p "$1" SUBCON1
  50.                 sub_answer "Your input is: "$SUBCON1". Are you sure ?(y/n) "
  51.                 if [ -z $SUBCON1 ]
  52.                 then
  53.                  SUBCON1="NULL"
  54.                 fi
  55.                 if [ $SUBANS == "y" ]
  56.                 then
  57.                 SUBCON2=$SUBCON1
  58.                 fi
  59.         done
  60. }
  61. #
  62. # sub_confirm end
  63. #

  64. sub_confirm "Please input the mount point full path: ?"


  65. ls -l  $SUBCON1* || exit

  66. for i in {0..9}
  67. do
  68. mknod /dev/loop$i b 7 $i  2>/dev/null
  69. done

  70. sub_answer() {
  71.         unset SUBANS
  72.         #
  73.         # Sub_sub_answer begin:
  74.         #
  75.         # Written by a RHCE, Tang Bo. Report Bugs to "tangbo@fjirsm.ac.cn".
  76.         # Version 1.0. Last modified on Jan 13rd 2007:
  77.         # 1.0   Original
  78.         sub_sub_answer(){
  79.                 SUBANS=`echo $SUBANS |tr -d "[:blank:]"`
  80.                 if [ -z $SUBANS ]
  81.                 then
  82.                 SUBANS="NULL"
  83.                 fi
  84.         }
  85.         #
  86.         # Sub_sub_answer end.
  87.         #
  88.         read -p "$1" SUBANS
  89.         sub_sub_answer # Line15
  90.         # Line15 begin: Deal with $SUNANS:
  91.         until [ $SUBANS ==  "y"  -o  $SUBANS ==  "n" ]
  92.         do
  93.                 echo "This question should be answered either with "y" or "n"."
  94.                 read -p "$1" SUBANS
  95.                 sub_sub_answer
  96.         done
  97.         # Line15 end.
  98. }



  99. mkdir /file 2>/dev/null
  100. mkdir /file/loop0 2>/dev/null
  101. mkdir /file/loop1  2>/dev/null
  102. mkdir /file/loop2  2>/dev/null
  103. mkdir /file/loop3  2>/dev/null
  104. mkdir /file/loop4  2>/dev/null
  105. mkdir /file/loop5  2>/dev/null
  106. mkdir /file/loop6 2>/dev/null
  107. mkdir /file/loop7 2>/dev/null
  108. mkdir /file/loop8  2>/dev/null
  109. mkdir /file/loop9  2>/dev/null

  110. echo "AuthName some" > /file/.htaccess
  111. echo "AuthType Basic" >> /file/.htaccess
  112. echo "AuthUserfile /etc/httpd/passwd/passwd" >> /file/.htaccess
  113. echo "require valid-user" >> /file/.htaccess

  114. for i in {0..9}
  115. do
  116. VBO=`find  $SUBCON1 -name "*.loop$i"`
  117. if [ ! -z $VBO ]
  118. then
  119.   sub_answer "Decrypt $VBO:(y/n)? "
  120.   if [ $SUBANS == 'y' ]
  121.   then
  122.    losetup  /dev/loop$i $VBO 2>/dev/null
  123.    losetup -f  /dev/loop$i $VBO 2>/dev/null
  124.    losetup  /dev/loop$i 2>/dev/null
  125.    cryptsetup luksOpen /dev/loop$i loop$i
  126.    mount -o ro /dev/mapper/loop$i /file/loop$i
  127.    # mount --bind /file/loop$i /container/loop$i
  128.   fi
  129. fi
  130. done

  131. df -h

  132. sleep 2

  133. ls -l /dev/mapper/
复制代码

bwmf:
  1. #!/bin/sh
  2. sub_confirm() {
  3.         #
  4.         # Sub_answer begin:
  5.         #
  6.         # Written by a RHCE, Tang Bo. Report Bugs to "tangbo@fjirsm.ac.cn".
  7.         # Version 1.1.1. Last modified on Jan 13rd 2007:
  8.         # 1.0   Original
  9.         # 1.1   Introduce "sub_sub_answer()"
  10.         # 1.1.1 "BFS1(Bash Format Standard V1)" applied
  11.         sub_answer() {
  12.                 unset SUBANS
  13.                 #
  14.                 # Sub_sub_answer begin:
  15.                 #
  16.                 # Written by a RHCE, Tang Bo. Report Bugs to "tangbo@fjirsm.ac.cn".
  17.                 # Version 1.0. Last modified on Jan 13rd 2007:
  18.                 # 1.0   Original
  19.                 sub_sub_answer(){
  20.                         SUBANS=`echo $SUBANS |tr -d "[:blank:]"`
  21.                         if [ -z $SUBANS ]
  22.                         then
  23.                         SUBANS="NULL"
  24.                         fi
  25.                 }
  26.                 #
  27.                 # Sub_sub_answer end.
  28.                 #
  29.                 read -p "$1" SUBANS
  30.                 sub_sub_answer # Line15
  31.                 # Line15 begin: Deal with $SUNANS:
  32.                 until [ $SUBANS ==  "y"  -o  $SUBANS ==  "n" ]
  33.                 do
  34.                         echo "This question should be answered either with "y" or "n"."
  35.                         read -p "$1" SUBANS
  36.                         sub_sub_answer
  37.                 done
  38.                 # Line15 end.
  39.         }
  40.         #
  41.         # Sub_answer end.
  42.         #
  43.         unset SUBCON1
  44.         unset SUBCON2
  45.         SUBCON1=0
  46.         SUBCON2=1
  47.         until [ $SUBCON1 == $SUBCON2 ]
  48.         do
  49.                 read -p "$1" SUBCON1
  50.                 sub_answer "Your input is: "$SUBCON1". Are you sure ?(y/n) "
  51.                 if [ -z $SUBCON1 ]
  52.                 then
  53.                  SUBCON1="NULL"
  54.                 fi
  55.                 if [ $SUBANS == "y" ]
  56.                 then
  57.                 SUBCON2=$SUBCON1
  58.                 fi
  59.         done
  60. }
  61. #
  62. # sub_confirm end
  63. #

  64. sub_confirm "Please input the mount point full path: ?"


  65. ls -l  $SUBCON1* || exit

  66. for i in {0..9}
  67. do
  68. mknod /dev/loop$i b 7 $i  2>/dev/null
  69. done

  70. sub_answer() {
  71.         unset SUBANS
  72.         #
  73.         # Sub_sub_answer begin:
  74.         #
  75.         # Written by a RHCE, Tang Bo. Report Bugs to "tangbo@fjirsm.ac.cn".
  76.         # Version 1.0. Last modified on Jan 13rd 2007:
  77.         # 1.0   Original
  78.         sub_sub_answer(){
  79.                 SUBANS=`echo $SUBANS |tr -d "[:blank:]"`
  80.                 if [ -z $SUBANS ]
  81.                 then
  82.                 SUBANS="NULL"
  83.                 fi
  84.         }
  85.         #
  86.         # Sub_sub_answer end.
  87.         #
  88.         read -p "$1" SUBANS
  89.         sub_sub_answer # Line15
  90.         # Line15 begin: Deal with $SUNANS:
  91.         until [ $SUBANS ==  "y"  -o  $SUBANS ==  "n" ]
  92.         do
  93.                 echo "This question should be answered either with "y" or "n"."
  94.                 read -p "$1" SUBANS
  95.                 sub_sub_answer
  96.         done
  97.         # Line15 end.
  98. }



  99. mkdir /file 2>/dev/null
  100. mkdir /file/loop0 2>/dev/null
  101. mkdir /file/loop1  2>/dev/null
  102. mkdir /file/loop2  2>/dev/null
  103. mkdir /file/loop3  2>/dev/null
  104. mkdir /file/loop4  2>/dev/null
  105. mkdir /file/loop5  2>/dev/null
  106. mkdir /file/loop6 2>/dev/null
  107. mkdir /file/loop7 2>/dev/null
  108. mkdir /file/loop8  2>/dev/null
  109. mkdir /file/loop9  2>/dev/null

  110. echo "AuthName some" > /file/.htaccess
  111. echo "AuthType Basic" >> /file/.htaccess
  112. echo "AuthUserfile /etc/httpd/passwd/passwd" >> /file/.htaccess
  113. echo "require valid-user" >> /file/.htaccess

  114. for i in {0..9}
  115. do
  116. VBO=`find  $SUBCON1 -name "*.loop$i"`
  117. if [ ! -z $VBO ]
  118. then
  119.   sub_answer "Decrypt $VBO:(y/n)? "
  120.   if [ $SUBANS == 'y' ]
  121.   then
  122.    losetup  /dev/loop$i $VBO 2>/dev/null
  123.    losetup -f  /dev/loop$i $VBO 2>/dev/null
  124.    losetup  /dev/loop$i 2>/dev/null
  125.    cryptsetup luksOpen /dev/loop$i loop$i
  126.    mount /dev/mapper/loop$i /file/loop$i
  127.    # mount --bind /file/loop$i /container/loop$i
  128.   fi
  129. fi
  130. done

  131. df -h

  132. sleep 2

  133. ls -l /dev/mapper/
复制代码

bumf:
  1. #!/bin/sh

  2. . /usr/lib/botang-func

  3. sub_confirm "Please input the mount point full path: ?"
  4. ls -l  $SUBCON1* || exit


  5. for i in {0..9}
  6. do
  7. VBO=`find  $SUBCON1 -name "*.loop$i"`
  8. if [ ! -z $VBO ]
  9. then
  10.   sub_answer "Decrypt $VBO:(y/n)? "
  11.   if [ $SUBANS == 'y' ]
  12.   then
  13.    # umount  /container/loop$i
  14.    umount  /file/loop$i
  15.    cryptsetup luksClose loop$i
  16.    losetup -d /dev/loop$i
  17.    losetup  /dev/loop$i 2>/dev/null
  18.   fi
  19. fi
  20. done



  21. df -h

  22. sleep 2
  23. ls -l /dev/mapper/
复制代码

botang-create-luks:

  1. #!/bin/sh

  2. . /usr/lib/botang-func


  3. read -p "File: " v_file


  4. sub_answer "DD? "
  5. if [ $SUBANS == y ]
  6. then
  7. read -p "SIZE(M): " v_size
  8. dd if=/dev/zero of=$v_file bs=4M count=$[ $v_size/4  ]
  9. fi

  10. for i in {0..9}
  11. do
  12. losetup /dev/loop$i
  13. done

  14. read -p "Loop(0-9): " v_loop


  15. losetup /dev/loop$v_loop $v_file
  16. cryptsetup luksFormat   /dev/loop$v_loop

  17. sub_answer "EXT4? "
  18. if [ $SUBANS == y ]
  19. then
  20. cryptsetup luksOpen /dev/loop$v_loop loop$v_loop
  21. mkfs.ext4 /dev/mapper/loop$v_loop
  22. fi
复制代码

botang-func:

  1. ####
  2. ####  1 Common Sub-program Section Begin
  3. ###   1.1 sub_answer Begin
  4. ###

  5. ###
  6. ###   0 sub_waiting
  7. ###

  8. sub_waiting() {
  9. echo
  10. echo
  11. echo
  12. echo
  13. echo
  14. jobs
  15. echo
  16. echo
  17. echo
  18. echo
  19. echo
  20. echo "Waiting 15s......"
  21. sleep 15
  22. while [ ! -z "$(jobs)" ]
  23. do
  24.   echo
  25.   echo
  26.   echo
  27.   jobs
  28.   echo
  29.   echo
  30.   echo
  31.   sub_answer "Wait 5s more(y/n): "
  32.   if [ $SUBANS == y ]
  33.   then
  34.    echo "Waiting 5s......"
  35.    sleep 5
  36.   else
  37.    break
  38.   fi
  39. done
  40. }




  41. v_ssh="nice -n -20 /usr/bin/ssh -q -o ConnectTimeout=60 -o StrictHostKeyChecking=no -o NumberOfPasswordPrompts=1 -o ConnectionAttempts=20"
  42. v_scp="nice -n -20 /usr/bin/scp -q -o ConnectTimeout=60 -o StrictHostKeyChecking=no -o NumberOfPasswordPrompts=1 -o ConnectionAttempts=20"


  43. sub_answer() {
  44.         unset SUBANS
  45.         #
  46.         # Sub_sub_answer begin:
  47.         #
  48.         # Written by a RHCE, Tang Bo. Report Bugs to "tangbo@fjirsm.ac.cn".
  49.         # Version 1.0. Last modified on Jan 13rd 2007:
  50.         # 1.0   Original
  51.         sub_sub_answer(){
  52.                 SUBANS=`echo $SUBANS |tr -d "[:blank:]"`
  53.                 if [ -z $SUBANS ]
  54.                 then
  55.                 SUBANS="NULL"
  56.                 fi
  57.         }
  58.         #
  59.         # Sub_sub_answer end.
  60.         #
  61.         read -p "$1" SUBANS
  62.         sub_sub_answer # Line15
  63.         # Line15 begin: Deal with $SUNANS:
  64.         until [ $SUBANS ==  "y"  -o  $SUBANS ==  "n" ]
  65.         do
  66.                 echo "This question should be answered either with "y" or "n"."
  67.                 read -p "$1" SUBANS
  68.                 sub_sub_answer
  69.         done
  70.         # Line15 end.
  71. }

  72. ###
  73. ###   1.1 sub_answer End
  74. ###   1.2 sub_confirm Begin
  75. ###

  76. sub_confirm() {
  77.         #
  78.         # Sub_answer begin:
  79.         #
  80.         # Written by a RHCE, Tang Bo. Report Bugs to "tangbo@fjirsm.ac.cn".
  81.         # Version 1.1.1. Last modified on Jan 13rd 2007:
  82.         # 1.0   Original
  83.         # 1.1   Introduce "sub_sub_answer()"
  84.         # 1.1.1 "BFS1(Bash Format Standard V1)" applied
  85.         sub_answer() {
  86.                 unset SUBANS
  87.                 #
  88.                 # Sub_sub_answer begin:
  89.                 #
  90.                 # Written by a RHCE, Tang Bo. Report Bugs to "tangbo@fjirsm.ac.cn".
  91.                 # Version 1.0. Last modified on Jan 13rd 2007:
  92.                 # 1.0   Original
  93.                 sub_sub_answer(){
  94.                         SUBANS=`echo $SUBANS |tr -d "[:blank:]"`
  95.                         if [ -z $SUBANS ]
  96.                         then
  97.                         SUBANS="NULL"
  98.                         fi
  99.                 }
  100.                 #
  101.                 # Sub_sub_answer end.
  102.                 #
  103.                 read -p "$1" SUBANS
  104.                 sub_sub_answer # Line15
  105.                 # Line15 begin: Deal with $SUNANS:
  106.                 until [ $SUBANS ==  "y"  -o  $SUBANS ==  "n" ]
  107.                 do
  108.                         echo "This question should be answered either with "y" or "n"."
  109.                         read -p "$1" SUBANS
  110.                         sub_sub_answer
  111.                 done
  112.                 # Line15 end.
  113.         }
  114.         #
  115.         # Sub_answer end.
  116.         #
  117.         unset SUBCON1
  118.         unset SUBCON2
  119.         SUBCON1=0
  120.         SUBCON2=1
  121.         until [ $SUBCON1 == $SUBCON2 ]
  122.         do
  123.                 read -p "$1" SUBCON1
  124.                 sub_answer "Input is: "$SUBCON1". Are you sure ?(y/n)"
  125.                 if [ -z $SUBCON1 ]
  126.                 then
  127.                  SUBCON1="NULL"
  128.                 fi
  129.                 if [ $SUBANS == "y" ]
  130.                 then
  131.                 SUBCON2=$SUBCON1
  132.                 fi
  133.         done
  134. }

  135. ###
  136. ###   1.2 sub_confirm End
  137. ###   1.3 sub_echo Begin
  138. ###

  139. sub_echo_red() {
  140. v_lang=$(echo $LANG | cut -f 1 -d '.')
  141. if [ $v_lang == "en_US" ]
  142. then
  143.   echo -e "\033[31;1m${1}\033[0m"
  144. elif [ $LANG == "zh_CN.GB18030" ]
  145.   then
  146.    echo -e "\033[31;1m${2}\033[0m"
  147. else
  148.   echo -e "\033[31;1m${1}\033[0m"
  149. fi
  150. }

  151. sub_echo_red_n() {
  152. v_lang=$(echo $LANG | cut -f 1 -d '.')
  153. if [ $v_lang == "en_US" ]
  154. then
  155.   echo -e -n "\033[31;1m${1}\033[0m"
  156. elif [ $LANG == "zh_CN.GB18030" ]
  157.   then
  158.    echo -e -n "\033[31;1m${2}\033[0m"
  159. else
  160.   echo -e -n "\033[31;1m${1}\033[0m"
  161. fi
  162. }

  163. sub_echo_green() {
  164. v_lang=$(echo $LANG | cut -f 1 -d '.')
  165. if [ $v_lang == "en_US" ]
  166. then
  167.   echo -e "\033[32;1m${1}\033[0m"
  168. elif [ $LANG == "zh_CN.GB18030" ]
  169.   then
  170.    echo -e "\033[32;1m${2}\033[0m"
  171. else
  172.   echo -e "\033[32;1m${1}\033[0m"
  173. fi
  174. }

  175. sub_echo_green_n() {
  176. v_lang=$(echo $LANG | cut -f 1 -d '.')
  177. if [ $v_lang == "en_US" ]
  178. then
  179.   echo -e -n "\033[32;1m${1}\033[0m"
  180. elif [ $LANG == "zh_CN.GB18030" ]
  181.   then
  182.    echo -e -n "\033[32;1m${2}\033[0m"
  183. else
  184.   echo -e -n "\033[32;1m${1}\033[0m"
  185. fi
  186. }

  187. sub_echo_green_blink() {
  188. v_lang=$(echo $LANG | cut -f 1 -d '.')
  189. if [ $v_lang == "en_US" ]
  190. then
  191.   echo -e "\033[32;5;1m${1}\033[0m"
  192. elif [ $LANG == "zh_CN.GB18030" ]
  193.   then
  194.    echo -e "\033[32;5;1m${2}\033[0m"
  195. else
  196.   echo -e "\033[32;5;1m${1}\033[0m"
  197. fi
  198. }

  199. sub_echo_title() {
  200. sub_echo_red "--------------------------------------------------------------------------------" "--------------------------------------------------------------------------------"
  201. sub_echo_red "$1" "$2"
  202. sub_echo_red "--------------------------------------------------------------------------------" "--------------------------------------------------------------------------------"
  203. }

  204. ###
  205. ###   1.3 sub_echo End
  206. ###
复制代码



回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|Bo's Oracle Station   

GMT+8, 2024-5-3 19:09 , Processed in 0.041664 second(s), 24 queries .

快速回复 返回顶部 返回列表