SHOW:
|
|
- or go back to the newest paste.
| 1 | #! /bin/bash | |
| 2 | account_name=$1 | |
| 3 | channel_name=$2 | |
| 4 | PHosts=() | |
| 5 | - | PHosts[0]=$(ls /opt/cdn/wowza/NSACDN/conf/plph_PelReshet1Publish/ | grep publish.stream | awk -F "." '{print $1}' | uniq | awk 'NR==1 {print $1}')
|
| 5 | + | PHosts[0]=$(ls /opt/cdn/wowza/NSACDN/conf/${account_name}_${channel_name}Publish/ | grep publish.stream | awk -F "." '{print $1}' | uniq | awk 'NR==1 {print $1}')
|
| 6 | - | PHosts[1]=$(ls /opt/cdn/wowza/NSACDN/conf/plph_PelReshet1Publish/ | grep publish.stream | awk -F "." '{print $1}' | uniq | awk 'NR==2 {print $1}')
|
| 6 | + | PHosts[1]=$(ls /opt/cdn/wowza/NSACDN/conf/${account_name}_${channel_name}Publish/ | grep publish.stream | awk -F "." '{print $1}' | uniq | awk 'NR==2 {print $1}')
|
| 7 | function Quit () | |
| 8 | {
| |
| 9 | read -sn1 -p " `echo $'\n'` Do you want to exit? [y/n] `echo $'\n'` " answer2 | |
| 10 | ||
| 11 | if [ "${answer2}" = "y" ]
| |
| 12 | then | |
| 13 | exit 0 | |
| 14 | ||
| 15 | elif [ "${answer2}" = "n" ]
| |
| 16 | then | |
| 17 | Start | |
| 18 | ||
| 19 | else | |
| 20 | echo -e "\nIncorrect symbol!!!\n" | |
| 21 | Quit | |
| 22 | fi | |
| 23 | } | |
| 24 | ||
| 25 | function MoveToPublish () | |
| 26 | { echo "
| |
| 27 | -----------------------------------------/mnt/gfs/cust/${account_name}/content/-------------------------------------------------------------
| |
| 28 | " | |
| 29 | symlinks_count_1=$(find /mnt/gfs/cust/${account_name}/content/ -type l | grep ${channel_name} | grep publish.stream | wc -l)
| |
| 30 | echo "${symlinks_count_1} publish.stream symlinks founded"
| |
| 31 | symlinks_count_2=$(ls -l /mnt/gfs/cust/${account_name}/content/ | grep ${channel_name} | grep publish.stream | wc -l)
| |
| 32 | echo "${symlinks_count_2} publish.stream files founded"
| |
| 33 | symlinks_count_3=$(find /mnt/gfs/cust/${account_name}/content/ -type l | grep ${channel_name} | grep pub_group.smil | wc -l)
| |
| 34 | echo "${symlinks_count_3} pub_group.smil symlinks founded"
| |
| 35 | symlinks_count_4=$(ls -l /mnt/gfs/cust/${account_name}/content/ | grep ${channel_name} | grep pub_group.smil | wc -l)
| |
| 36 | echo "${symlinks_count_4} pub_group.smil files founded"
| |
| 37 | echo " | |
| 38 | -------------------------------/opt/cdn/wowza/NSACDN/conf/${account_name}_${channel_name}Repeat/---------------------------------------------
| |
| 39 | " | |
| 40 | symlinks_count_5=$(find /opt/cdn/wowza/NSACDN/conf/${account_name}_${channel_name}Repeat/ -type f | grep ${channel_name} | grep publish.stream | wc -l)
| |
| 41 | echo "${symlinks_count_5} publish.stream files founded in "
| |
| 42 | symlinks_count_6=$(find /mnt/gfs/cust/${account_name}/content/ -type f | grep ${channel_name} | grep pub_group.smil | wc -l)
| |
| 43 | echo "${symlinks_count_6} pub_group.smil files founded"
| |
| 44 | echo " | |
| 45 | --------------------------------------------------------------------------------------------------------------------------------------------- | |
| 46 | " | |
| 47 | ||
| 48 | if [ ${symlinks_count_1} > 0 ] && [ ${symlinks_count_2} = 0 ]
| |
| 49 | then | |
| 50 | ls -l /mnt/gfs/cust/${account_name}/content/ | grep ${channel_name} | grep publish.stream | awk '$10=="->"' | awk '{print $11}' | xargs -i svn mv {} /opt/cdn/wowza/NSACDN/conf/${account_name}_${channel_name}Publish/
| |
| 51 | ls -l /mnt/gfs/cust/${account_name}/content/ | grep ${channel_name} | grep publish.stream | xargs rm -v
| |
| 52 | elif [ ${symlinks_count_1} > 0 ] && [ ${symlinks_count_2} > 0 ]
| |
| 53 | then | |
| 54 | ls -l /mnt/gfs/cust/${account_name}/content/ | grep ${channel_name} | grep publish.stream | awk '$10=="->"' | awk '{print $11}' | xargs -i svn mv {} /opt/cdn/wowza/NSACDN/conf/${account_name}_${channel_name}Publish/
| |
| 55 | find /mnt/gfs/cust/${account_name}/content/ -type l | grep ${channel_name} | grep publish.stream | xargs rm -v
| |
| 56 | find /mnt/gfs/cust/${account_name}/content/ -type f | grep ${channel_name} | grep publish.stream | xargs -i svn mv {} /opt/cdn/wowza/NSACDN/conf/${account_name}_${channel_name}Publish/
| |
| 57 | elif [ ${symlinks_count_1} = 0 ] && [ ${symlinks_count_2} = 0 ]
| |
| 58 | then | |
| 59 | echo "No files have been found! " | |
| 60 | elif [ ${symlinks_count_1} = 0 ] && [ ${symlinks_count_2} > 0 ]
| |
| 61 | then | |
| 62 | find /mnt/gfs/cust/${account_name}/content/ -type f | grep ${channel_name} | grep publish.stream | xargs -i svn mv {} /opt/cdn/wowza/NSACDN/conf/${account_name}_${channel_name}Publish/
| |
| 63 | else | |
| 64 | echo "Unknown error" | |
| 65 | fi | |
| 66 | ||
| 67 | if [ ${symlinks_count_3} > 0 ] && [ ${symlinks_count_4} = 0 ]
| |
| 68 | then | |
| 69 | ls -l /mnt/gfs/cust/${account_name}/content/ | grep ${channel_name} | grep pub_group.smil | awk '$10=="->"' | awk '{print $11}' | xargs -i svn mv {} /opt/cdn/wowza/NSACDN/conf/${account_name}_${channel_name}Publish/
| |
| 70 | ls -l /mnt/gfs/cust/${account_name}/content/ | grep ${channel_name} | grep pub_group.smil | xargs rm -v
| |
| 71 | elif [ ${symlinks_count_3} > 0 ] && [ ${symlinks_count_4} > 0 ]
| |
| 72 | then | |
| 73 | ls -l /mnt/gfs/cust/${account_name}/content/ | grep ${channel_name} | grep pub_group.smil | awk '$10=="->"' | awk '{print $11}' | xargs -i svn mv {} /opt/cdn/wowza/NSACDN/conf/${account_name}_${channel_name}Publish/
| |
| 74 | find /mnt/gfs/cust/${account_name}/content/ -type l | grep ${channel_name} | grep pub_group.smil | xargs rm -v
| |
| 75 | find /mnt/gfs/cust/${account_name}/content/ -type f | grep ${channel_name} | grep pub_group.smil | xargs -i svn mv {} /opt/cdn/wowza/NSACDN/conf/${account_name}_${channel_name}Publish/
| |
| 76 | elif [ ${symlinks_count_3} = 0 ] && [ ${symlinks_count_4} = 0 ]
| |
| 77 | then | |
| 78 | echo "No files have been found! " | |
| 79 | elif [ ${symlinks_count_3} = 0 ] && [ ${symlinks_count_4} > 0 ]
| |
| 80 | then | |
| 81 | find /mnt/gfs/cust/${account_name}/content/ -type f | grep ${channel_name} | grep pub_group.smil | xargs -i svn mv {} /opt/cdn/wowza/NSACDN/conf/${account_name}_${channel_name}Publish/
| |
| 82 | else | |
| 83 | echo "Unknown error" | |
| 84 | fi | |
| 85 | ||
| 86 | if [ ${symlinks_count_5} > 0 ] || [ ${symlinks_count_6} > 0 ]
| |
| 87 | then | |
| 88 | find /opt/cdn/wowza/NSACDN/conf/${account_name}_${channel_name}Repeat/ -type f | grep ${channel_name} | grep _pub_group.smil | xargs -i svn mv {} /opt/cdn/wowza/NSACDN/conf/${account_name}_${channel_name}Publish/
| |
| 89 | find /opt/cdn/wowza/NSACDN/conf/${account_name}_${channel_name}Repeat/ -type f | grep ${channel_name} | grep publish.stream | xargs -i svn mv {} /opt/cdn/wowza/NSACDN/conf/${account_name}_${channel_name}Publish/
| |
| 90 | fi | |
| 91 | } | |
| 92 | ||
| 93 | function MoveToRepeat () | |
| 94 | {
| |
| 95 | echo "# of symlinks:" | |
| 96 | rep_count1=$(find /mnt/gfs/cust/${account_name}/content/ -type l | grep ${channel_name} | grep stream | grep -v publish.stream | wc -l)
| |
| 97 | echo "${rep_count1} for stream files"
| |
| 98 | ||
| 99 | rep_count2=$(find /mnt/gfs/cust/${account_name}/content/ -type l | grep ${channel_name} | grep smil |grep -v pub_group.smil | wc -l)
| |
| 100 | echo "${rep_count2} for smil files"
| |
| 101 | ||
| 102 | ||
| 103 | echo " | |
| 104 | # of files:" | |
| 105 | echo "for stream files" | |
| 106 | rep_count3=$(find /mnt/gfs/cust/${account_name}/content/ -type f | grep ${channel_name} | grep stream | grep -v publish.stream | wc -l)
| |
| 107 | echo "for smil files" | |
| 108 | rep_count4=$(find /mnt/gfs/cust/${account_name}/content/ -type f | grep ${channel_name} | grep smil | grep -v pub_group.smil | wc -l)
| |
| 109 | ||
| 110 | if [ ${rep_count1} > 0 ]
| |
| 111 | then | |
| 112 | ls -l /mnt/gfs/cust/${account_name}/content/ | grep ${channel_name} | grep stream | grep -v publish.stream | awk '$10=="->"' | awk '{print $11}' | xargs -i svn mv {} /opt/cdn/wowza/NSACDN/conf/${account_name}_${channel_name}Repeat/
| |
| 113 | ls -l /mnt/gfs/cust/${account_name}/content/ | grep ${channel_name} | grep stream | grep -v publish.stream | xargs rm -v
| |
| 114 | elif [ ${rep_count2} > 0 ]
| |
| 115 | then | |
| 116 | ls -l /mnt/gfs/cust/${account_name}/content/ | grep ${channel_name} | grep smil| grep -v pub_group.smil | awk '$10=="->"' | awk '{print $11}' | xargs -i svn mv {} /opt/cdn/wowza/NSACDN/conf/${account_name}_${channel_name}Repeat/
| |
| 117 | ls -l /mnt/gfs/cust/${account_name}/content/ | grep ${channel_name} | grep smil | grep -v pub_group.smil | xargs rm -v
| |
| 118 | elif [ ${rep_count3} > 0 ]
| |
| 119 | then | |
| 120 | find /opt/cdn/wowza/NSACDN/conf/${account_name}_${channel_name}Publish/ -type f | grep ${channel_name} | grep stream | grep -v publish.stream | xargs -i svn mv {} /opt/cdn/wowza/NSACDN/conf/${account_name}_${channel_name}Repeat/
| |
| 121 | elif [ ${rep_count4} > 0 ]
| |
| 122 | then | |
| 123 | find /opt/cdn/wowza/NSACDN/conf/${account_name}_${channel_name}Publish/ -type f | grep ${channel_name} | grep smil | grep -v _pub_group.smil | xargs -i svn mv {} /opt/cdn/wowza/NSACDN/conf/${account_name}_${channel_name}Repeat/
| |
| 124 | else | |
| 125 | echo "No files found" | |
| 126 | fi | |
| 127 | } | |
| 128 | ||
| 129 | - | svn add /opt/cdn/wowza4/NSACDN/conf/${account_name}_${channel_name}Repeat /opt/cdn/wowza/NSACDN/conf/${account_name}_${channel_name}Publish
|
| 129 | + | |
| 130 | - | svn update /opt/cdn/wowza4/NSACDN/conf/${account_name}_${channel_name}Repeat /opt/cdn/wowza/NSACDN/conf/${account_name}_${channel_name}Publish
|
| 130 | + | |
| 131 | svn add /opt/cdn/wowza/NSACDN/conf/${account_name}_${channel_name}Repeat /opt/cdn/wowza/NSACDN/conf/${account_name}_${channel_name}Publish
| |
| 132 | svn update /opt/cdn/wowza/NSACDN/conf/${account_name}_${channel_name}Repeat /opt/cdn/wowza/NSACDN/conf/${account_name}_${channel_name}Publish
| |
| 133 | svn commit -m 'Changed stream smil files folders' /opt/cdn/wowza/NSACDN/conf/${account_name}_${channel_name}Repeat /opt/cdn/wowza/NSACDN/conf/${account_name}_${channel_name}Publish
| |
| 134 | /opt/cdn/bin/pexec.sh "/opt/cdn/utils/svn update /opt/cdn/wowza/NSACDN/conf/${account_name}_${channel_name}Repeat /opt/cdn/wowza/NSACDN/conf/${account_name}_${channel_name}Publish" --zones=svn
| |
| 135 | } | |
| 136 | ||
| 137 | function ContentRemove () | |
| 138 | {
| |
| 139 | counter=$(find /mnt/gfs/cust/${account_name}/content/ -type f | grep ${channel_name} | wc -l)
| |
| 140 | ||
| 141 | if [ ${counter} = 0 ]
| |
| 142 | then | |
| 143 | /opt/cdn/bin/pexec.sh "find /mnt/gfs/cust/${account_name}/content/ | grep -E "${channel_name}" | xargs rm -vf" --zones=svn
| |
| 144 | else | |
| 145 | echo " | |
| 146 | ||
| 147 | ||
| 148 | Some files have been found!!! | |
| 149 | ||
| 150 | ||
| 151 | " | |
| 152 | Quit | |
| 153 | fi | |
| 154 | } | |
| 155 | ||
| 156 | function PublishApplicationChange () | |
| 157 | {
| |
| 158 | sed -i "s+/mnt/gfs/cust/${account_name}/content+/opt/cdn/wowza/NSACDN/conf/${account_name}_${channel_name}Publish+g" /opt/cdn/wowza/NSACDN/conf/${account_name}_${channel_name}Publish/Application.xml
| |
| 159 | sed -i "s+/mnt/gfs/cust/${account_name}/keys+/opt/cdn/wowza/NSACDN/conf/${account_name}_${channel_name}Publish+g" /opt/cdn/wowza/NSACDN/conf/${account_name}_${channel_name}Publish/Application.xml
| |
| 160 | cat /opt/cdn/wowza/NSACDN/conf/${account_name}_${channel_name}Publish/Application.xml | grep -E "/opt/cdn/wowza/NSACDN/conf/"
| |
| 161 | } | |
| 162 | ||
| 163 | function RepeatApplicationChange () | |
| 164 | {
| |
| 165 | sed -i "s+/mnt/gfs/cust/${account_name}/content+/opt/cdn/wowza/NSACDN/conf/${account_name}_${channel_name}Repeat+g" /opt/cdn/wowza/NSACDN/conf/${account_name}_${channel_name}Repeat/Application.xml
| |
| 166 | sed -i "s+/mnt/gfs/cust/${account_name}/keys+/opt/cdn/wowza/NSACDN/conf/${account_name}_${channel_name}Repeat+g" /opt/cdn/wowza/NSACDN/conf/${account_name}_${channel_name}Repeat/Application.xml
| |
| 167 | cat /opt/cdn/wowza/NSACDN/conf/${account_name}_${channel_name}Repeat/Application.xml | grep -E "/opt/cdn/wowza/NSACDN/conf/"
| |
| 168 | } | |
| 169 | ||
| 170 | - | /opt/cdn/bin/pexec.sh "ln -s /opt/cdn/wowza/NSACDN/conf/plph_PelReshetHDPublish/PelReshetHD_pub_group.smil /mnt/gfs/cust/plph/content/" --hosts=${PHosts[0]}
|
| 170 | + | |
| 171 | - | /opt/cdn/bin/pexec.sh "ln -s /opt/cdn/wowza/NSACDN/conf/plph_PelReshetHDPublish/*publish.stream /mnt/gfs/cust/plph/content/" --hosts=${PHosts[1]}
|
| 171 | + | |
| 172 | /opt/cdn/bin/pexec.sh "ln -s /opt/cdn/wowza/NSACDN/conf/${account_name}_${channel_name}Publish/${channel_name}_pub_group.smil /mnt/gfs/cust/${account_name}/content/" --hosts=${PHosts[0]},${PHosts[1]}
| |
| 173 | ||
| 174 | /opt/cdn/bin/pexec.sh "ln -vs /opt/cdn/wowza/NSACDN/conf/${account_name}_${channel_name}Publish/${PHosts[0]}* /mnt/gfs/cust/${account_name}/content/" --hosts=${PHosts[0]}
| |
| 175 | /opt/cdn/bin/pexec.sh "rename -v 's%${PHosts[0]}.%%' /mnt/gfs/cust/${account_name}/content/*publish.stream" --hosts=${PHosts[0]}
| |
| 176 | ||
| 177 | /opt/cdn/bin/pexec.sh "ln -vs /opt/cdn/wowza/NSACDN/conf/${account_name}_${channel_name}Publish/${PHosts[0]}* /mnt/gfs/cust/${account_name}/content/" --hosts=${PHosts[1]}
| |
| 178 | /opt/cdn/bin/pexec.sh "rename -v 's%${PHosts[1]}.%%' /mnt/gfs/cust/${account_name}/content/*publish.stream" --hosts=${PHosts[1]}
| |
| 179 | } | |
| 180 | ||
| 181 | function Start () | |
| 182 | {
| |
| 183 | read -sn1 -p " `echo $'\n'` What do you want to do? | |
| 184 | 1 - Move _pub_group.smil and publish.stream files from ll /mnt/gfs/cust/${account_name}/content/ directory to /opt/cdn/wowza/NSACDN/conf/${account_name}_${channel_name}Publish/ for ${channel_name} channel ?
| |
| 185 | 2 - Move stream and publish files for ${channel_name} channel from /mnt/gfs/cust/${account_name}/content/ to /opt/cdn/wowza/NSACDN/conf/${account_name}_${channel_name}Repeat/ ?
| |
| 186 | 3 - Change StorageDir and KeyDir on Application.xml in /opt/cdn/wowza/NSACDN/conf/${account_name}_${channel_name}Publish/ ?
| |
| 187 | 4 - Change StorageDir and KeyDir on Application.xml in /opt/cdn/wowza/NSACDN/conf/${account_name}_${channel_name}Repeat/ ?
| |
| 188 | 5 - Sync /opt/cdn/wowza/NSACDN/conf/${account_name}_${channel_name}Repeat/ and /opt/cdn/wowza/NSACDN/conf/${account_name}_${channel_name}Publish/ folders for SVN zone ?
| |
| 189 | 6 - Remove /mnt/gfs/cust/${account_name}/content/ files for ${channel_name} channel ?
| |
| 190 | 7 - Make symlinks for pub_group smil and publish.stream files | |
| 191 | 8 - All of the above. | |
| 192 | 0 - Exit ? `echo $'\n'` " answer0 | |
| 193 | ||
| 194 | case ${answer0} in "1")
| |
| 195 | MoveToPublish | |
| 196 | Quit ;; | |
| 197 | "2") | |
| 198 | MoveToRepeat | |
| 199 | Quit ;; | |
| 200 | "3") | |
| 201 | PublishApplicationChange | |
| 202 | Quit ;; | |
| 203 | "4") | |
| 204 | RepeatApplicationChange | |
| 205 | Quit ;; | |
| 206 | "5") | |
| 207 | SVNSync | |
| 208 | Quit ;; | |
| 209 | "6") | |
| 210 | ContentRemove | |
| 211 | Quit ;; | |
| 212 | "7") | |
| 213 | SymlinksMaker | |
| 214 | Quit ;; | |
| 215 | "8") | |
| 216 | MoveToPublish | |
| 217 | MoveToRepeat | |
| 218 | PublishApplicationChange | |
| 219 | RepeatApplicationChange | |
| 220 | SVNSync | |
| 221 | ContentRemove | |
| 222 | Quit;; | |
| 223 | "0") | |
| 224 | exit 0 | |
| 225 | Quit ;; | |
| 226 | esac | |
| 227 | } | |
| 228 | ||
| 229 | if [ -z "${account_name}" ]
| |
| 230 | then | |
| 231 | echo -e "\nAccount name wasn't set\n" | |
| 232 | exit 0 | |
| 233 | ||
| 234 | elif [ -z "${channel_name}" ]
| |
| 235 | then | |
| 236 | echo -e "\nChannel name wasn't set\n" | |
| 237 | exit 0 | |
| 238 | else | |
| 239 | Start | |
| 240 | fi |