-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNextNoti.sh
69 lines (60 loc) · 2.11 KB
/
NextNoti.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
blue(){
echo -e "\033[34m\033[01m$1\033[0m"
}
green(){
echo -e "\033[32m\033[01m$1\033[0m"
}
yellow(){
echo -e "\033[33m\033[01m$1\033[0m"
}
red(){
echo -e "\033[31m\033[01m$1\033[0m"
}
#输入Cloud的Name
green "======================================="
green " 请输入容器名 "
green "======================================="
read Container_Names
#自动获取Container ID
Cloud_ID=`docker ps --format "table {{.ID}}\{{.Names}}" | egrep $Container_Names$ | cut -c 1-12`
#统计行数
UserCount=`docker exec --user www-data $Cloud_ID php occ user:list | grep -c - | cut -c 1-2`
#判别容器是否存在
if [[ $Cloud_ID == "" ]]; then
red "======================================="
red " 该容器不存在,请重新输入! "
red "======================================="
exit 0
fi
#输入标题
green "======================================="
green " 请输入公告标题 "
green "======================================="
read header
#输入正文
green "======================================="
green " 请输入正文内容 "
green "======================================="
read -r notes
#确认发布内容
green "======================================="
green " 请核对公告内容 "
yellow " 公告标题为:$header "
yellow " 公告内容为:$notes "
green "======================================="
green " 是否确认发布(Y/N) "
read choice_pub
if [[ $choice_pub == "y" ]]||[[ $choice_pub == "Y" ]]; then
for ((i=1; i<=$UserCount; i=i+1))
do
CloudUser=`docker exec --user www-data $Cloud_ID php occ user:list | grep - | cut -d: -f2 | sed -n ''$i','$i'p'`
docker exec --user www-data $Cloud_ID php occ notification:generate $CloudUser "$header" -l "$notes"
done
fi
#输出确认
blue "======================================="
blue " 已将新公告发送给指定用户 "
blue "======================================="
echo "退出程序"
exit 0