├── 404.html
├── CNAME
├── README.md
├── _config.yml
├── assets
└── print.css
├── css.sh
├── favicon.ico
├── hls.sh
└── stream.sh
/404.html:
--------------------------------------------------------------------------------
1 |
2 | 404
3 |
4 |
5 |
--------------------------------------------------------------------------------
/CNAME:
--------------------------------------------------------------------------------
1 | ls.fanmingming.com
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 
2 | ## stream.sh
3 | - 【无人值守直播】将本地指定目录下的MP4文件循环推送到B站或Youtube等直播平台的脚本(适用于Ubuntu、Debian和RaspberryPi OS等Linux系统)
4 | ```
5 | //安装screen
6 | sudo apt install screen
7 | //创建一个窗口
8 | screen -S stream
9 | //下载脚本
10 | wget https://ls.fanmingming.com/stream.sh
11 | //执行脚本
12 | bash stream.sh
13 | ```
14 |
15 | ## hls.sh
16 | - 通过ffmpeg利用Web环境实现拉取任意直播流并推流的脚本(适用于Ubuntu、Debian和RaspberryPi OS等Linux系统)
17 | ```
18 | //安装screen
19 | sudo apt install screen
20 | //创建一个窗口
21 | screen -S hls
22 | //下载脚本
23 | wget https://ls.fanmingming.com/hls.sh
24 | //执行脚本
25 | bash hls.sh
26 | ```
27 |
--------------------------------------------------------------------------------
/_config.yml:
--------------------------------------------------------------------------------
1 | title: 一些Linux脚本
2 | description: 一些Linux脚本。
3 | remote_theme: pages-themes/tactile@v0.2.0
4 | plugins:
5 | - jekyll-remote-theme # add this line to the plugins list if you already have one
6 |
--------------------------------------------------------------------------------
/assets/print.css:
--------------------------------------------------------------------------------
1 | ---
2 | ---
3 |
4 | html, body, div, span, applet, object, iframe,
5 | h1, h2, h3, h4, h5, h6, p, blockquote, pre,
6 | a, abbr, acronym, address, big, cite, code,
7 | del, dfn, em, img, ins, kbd, q, s, samp,
8 | small, strike, strong, sub, sup, tt, var,
9 | b, u, i, center,
10 | dl, dt, dd, ol, ul, li,
11 | fieldset, form, label, legend,
12 | table, caption, tbody, tfoot, thead, tr, th, td,
13 | article, aside, canvas, details, embed,
14 | figure, figcaption, footer, header, hgroup,
15 | menu, nav, output, ruby, section, summary,
16 | time, mark, audio, video {
17 | padding: 0;
18 | margin: 0;
19 | font: inherit;
20 | font-size: 100%;
21 | vertical-align: baseline;
22 | border: 0;
23 | }
24 | /* HTML5 display-role reset for older browsers */
25 | article, aside, details, figcaption, figure,
26 | footer, header, hgroup, menu, nav, section {
27 | display: block;
28 | }
29 | body {
30 | line-height: 1;
31 | }
32 | ol, ul {
33 | list-style: none;
34 | }
35 | blockquote, q {
36 | quotes: none;
37 | }
38 | blockquote:before, blockquote:after,
39 | q:before, q:after {
40 | content: '';
41 | content: none;
42 | }
43 | table {
44 | border-spacing: 0;
45 | border-collapse: collapse;
46 | }
47 | body {
48 | font-family: 'Helvetica Neue', Helvetica, Arial, serif;
49 | font-size: 13px;
50 | line-height: 1.5;
51 | color: #000;
52 | }
53 |
54 | a {
55 | font-weight: bold;
56 | color: #d5000d;
57 | }
58 |
59 | header {
60 | padding-top: 35px;
61 | padding-bottom: 10px;
62 | }
63 |
64 | header h1 {
65 | font-size: 48px;
66 | font-weight: bold;
67 | line-height: 1.2;
68 | color: #303030;
69 | letter-spacing: -1px;
70 | }
71 |
72 | header h2 {
73 | font-size: 24px;
74 | font-weight: normal;
75 | line-height: 1.3;
76 | color: #aaa;
77 | letter-spacing: -1px;
78 | }
79 | #downloads {
80 | display: none;
81 | }
82 | #main_content {
83 | padding-top: 20px;
84 | }
85 |
86 | code, pre {
87 | margin-bottom: 30px;
88 | font-family: Monaco, "Bitstream Vera Sans Mono", "Lucida Console", Terminal;
89 | font-size: 12px;
90 | color: #222;
91 | }
92 |
93 | code {
94 | padding: 0 3px;
95 | }
96 |
97 | pre {
98 | padding: 20px;
99 | overflow: auto;
100 | border: solid 1px #ddd;
101 | }
102 | pre code {
103 | padding: 0;
104 | }
105 |
106 | ul, ol, dl {
107 | margin-bottom: 20px;
108 | }
109 |
110 |
111 | /* COMMON STYLES */
112 |
113 | table {
114 | width: 100%;
115 | border: 1px solid #ebebeb;
116 | }
117 |
118 | th {
119 | font-weight: 500;
120 | }
121 |
122 | td {
123 | font-weight: 300;
124 | text-align: center;
125 | border: 1px solid #ebebeb;
126 | }
127 |
128 | form {
129 | padding: 20px;
130 | background: #f2f2f2;
131 |
132 | }
133 |
134 |
135 | /* GENERAL ELEMENT TYPE STYLES */
136 |
137 | h1 {
138 | font-size: 2.8em;
139 | }
140 |
141 | h2 {
142 | margin-bottom: 8px;
143 | font-size: 22px;
144 | font-weight: bold;
145 | color: #303030;
146 | }
147 |
148 | h3 {
149 | margin-bottom: 8px;
150 | font-size: 18px;
151 | font-weight: bold;
152 | color: #d5000d;
153 | }
154 |
155 | h4 {
156 | font-size: 16px;
157 | font-weight: bold;
158 | color: #303030;
159 | }
160 |
161 | h5 {
162 | font-size: 1em;
163 | color: #303030;
164 | }
165 |
166 | h6 {
167 | font-size: .8em;
168 | color: #303030;
169 | }
170 |
171 | p {
172 | margin-bottom: 20px;
173 | font-weight: 300;
174 | }
175 |
176 | a {
177 | text-decoration: none;
178 | }
179 |
180 | p a {
181 | font-weight: 400;
182 | }
183 |
184 | blockquote {
185 | padding: 0 0 0 30px;
186 | margin-bottom: 20px;
187 | font-size: 1.6em;
188 | border-left: 10px solid #e9e9e9;
189 | }
190 |
191 | ul li {
192 | padding-left: 20px;
193 | list-style-position: inside;
194 | list-style: disc;
195 | }
196 |
197 | ol li {
198 | padding-left: 3px;
199 | list-style-position: inside;
200 | list-style: decimal;
201 | }
202 |
203 | dl dd {
204 | font-style: italic;
205 | font-weight: 100;
206 | }
207 |
208 | footer {
209 | padding-top: 20px;
210 | padding-bottom: 30px;
211 | margin-top: 40px;
212 | font-size: 13px;
213 | color: #aaa;
214 | }
215 |
216 | footer a {
217 | color: #666;
218 | }
219 |
220 | /* MISC */
221 | .clearfix:after {
222 | display: block;
223 | height: 0;
224 | clear: both;
225 | visibility: hidden;
226 | content: '.';
227 | }
228 |
229 | .clearfix {display: inline-block;}
230 | * html .clearfix {height: 1%;}
231 | .clearfix {display: block;}
232 |
--------------------------------------------------------------------------------
/css.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # CSS服务器脚本 ubuntu 18.04 X64
3 | # https://developer.valvesoftware.com/wiki/SteamCMD:zh-cn
4 |
5 | sudo apt update -y;
6 | sudo apt upgrade -y;
7 |
8 | sudo apt install lib32gcc1 -y;
9 | sudo apt install libc6-i386 -y;
10 | sudo apt install lib32z1 -y;
11 | sudo apt install lib32tinfo5 -y;
12 | sudo apt install libsdl2-2.0-0:i386 -y;
13 |
14 | sudo apt install screen -y;
15 | sudo apt install wget -y;
16 | sudo apt install gzip -y;
17 | sudo apt install tar -y;
18 | sudo apt install vim -y;
19 |
20 | sudo useradd -m steam;
21 | sudo runuser -l steam -c 'mkdir /home/steam/steamcmd;';
22 | sudo runuser -l steam -c 'mkdir /home/steam/css;';
23 |
24 | sudo runuser -l steam -c 'cd /home/steam/steamcmd && curl -sqL "https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz" | tar zxvf -;';
25 | sudo runuser -l steam -c '/home/steam/steamcmd/steamcmd.sh +force_install_dir /home/steam/css +login anonymous +app_update 232330 +quit;';
26 |
27 | sudo runuser -l steam -c 'cd /home/steam/css/cstrike && wget https://mms.alliedmods.net/mmsdrop/1.11/mmsource-1.11.0-git1144-linux.tar.gz;';
28 | sudo runuser -l steam -c 'cd /home/steam/css/cstrike && tar -zxvf mmsource-1.11.0-git1144-linux.tar.gz;';
29 | sudo runuser -l steam -c 'cd /home/steam/css/cstrike && wget https://sm.alliedmods.net/smdrop/1.10/sourcemod-1.10.0-git6502-linux.tar.gz;';
30 | sudo runuser -l steam -c 'cd /home/steam/css/cstrike && tar -zxvf sourcemod-1.10.0-git6502-linux.tar.gz;';
31 |
32 | sudo rm -rf /home/steam/css/cstrike/sourcemod-1.10.0-git6502-linux.tar.gz /home/steam/css/cstrike/mmsource-1.11.0-git1144-linux.tar.gz;
33 |
34 | sudo runuser -l steam -c 'echo "\"(你的steamid填在这里)\" \"99:z\"" >> /home/steam/css/cstrike/addons/sourcemod/configs/admins_simple.ini';
35 |
36 | sudo runuser -l steam -c 'screen -S css /home/steam/css/srcds_run -console -game cstrike +map de_dust2;';
37 |
--------------------------------------------------------------------------------
/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fanmingming/LinuxScript/0023ca15e4b1607df44eb9624bd61e1cc6f72818/favicon.ico
--------------------------------------------------------------------------------
/hls.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | function show_menu {
4 | clear
5 | echo "请选择你的操作(输入数字):"
6 | echo "1. 安装ffmpeg"
7 | echo "2. 开始推流"
8 | echo "3. 停止推流"
9 | echo "4. 退出脚本"
10 | }
11 |
12 | function install_ffmpeg {
13 | echo "即将安装ffmpeg,是否继续?(yes/no)"
14 | read confirmation
15 | if [ "$confirmation" == "yes" ]; then
16 | echo "正在安装ffmpeg..."
17 | # 安装ffmpeg命令
18 | sudo apt-get update
19 | sudo apt-get install -y ffmpeg
20 | echo "ffmpeg安装完成"
21 | read -n 1 -s -r -p "按任意键继续..."
22 | fi
23 | }
24 |
25 | function start_stream {
26 | read -p "请输入拉流地址:" rtsp_address
27 | read -p "请输入www服务的路径(不能包含空格,结尾不要带/):" stream_path
28 | echo "开始推流:$rtsp_address -> $stream_path/index.m3u8"
29 | # 推流命令
30 | sudo ffmpeg -i "$rtsp_address" -c:v copy -c:a copy -hls_flags delete_segments -hls_segment_filename "$stream_path/index_%03d.ts" -hls_time 10 "$stream_path/index.m3u8"
31 | read -n 1 -s -r -p "按任意键继续..."
32 | }
33 |
34 | function stop_stream {
35 | # 停止推流命令
36 | sudo screen -S hls -X quit
37 | sudo killall ffmpeg
38 | echo "停止所有推流"
39 | read -n 1 -s -r -p "按任意键继续..."
40 | }
41 |
42 | show_menu
43 |
44 | while true; do
45 | read -p "请输入选项:" choice
46 | case $choice in
47 | 1) install_ffmpeg ;;
48 | 2) start_stream ;;
49 | 3) stop_stream ;;
50 | 4) exit ;;
51 | *) echo "无效的选项" ;;
52 | esac
53 | show_menu
54 | done
55 |
--------------------------------------------------------------------------------
/stream.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # 颜色选择
4 | red='\033[0;31m'
5 | green='\033[0;32m'
6 | yellow='\033[0;33m'
7 | font="\033[0m"
8 |
9 | ffmpeg_install(){
10 | # 安装FFMPEG
11 | read -p "安装FFmpeg才能正常推流,是否现在安装FFmpeg?(yes/no):" Choose
12 | if [ $Choose = "yes" ];then
13 | sudo apt update
14 | sudo apt install ffmpeg
15 | ffmpeg -version
16 | fi
17 | if [ $Choose = "no" ]
18 | then
19 | echo -e "${yellow} 你选择不安装FFmpeg! ${font}"
20 | sleep 2
21 | fi
22 | }
23 |
24 | stream_start(){
25 | # 定义推流地址和推流码
26 | read -p "输入推流地址和推流码(rtmp协议):" rtmp
27 |
28 | # 判断用户输入的地址是否合法
29 | if [[ $rtmp =~ "rtmp://" ]];then
30 | echo -e "${green} 推流地址输入正确,程序将进行下一步操作. ${font}"
31 | sleep 2
32 | else
33 | echo -e "${red} 输入的地址不正确,请重新运行程序并输入! ${font}"
34 | exit 1
35 | fi
36 |
37 | # 定义视频存放目录
38 | read -p "输入视频存放目录 (格式支持mp4,并且要绝对路径,例如/opt/video):" folder
39 |
40 | # 判断是否需要添加水印
41 | read -p "是否需要为视频添加水印?水印位置默认在右上方(yes/no):" watermark
42 | if [ $watermark = "yes" ];then
43 | read -p "输入水印图片存放绝对路径,例如/opt/image/watermark.jpg (格式支持jpg/png/bmp):" image
44 | echo -e "${yellow} 添加水印完成,程序将开始推流. ${font}"
45 | # 循环
46 | while true
47 | do
48 | cd $folder
49 | for video in $(ls *.mp4)
50 | do
51 | ffmpeg -re -i "$video" -i "$image" -filter_complex overlay=W-w-5:5 -c:v libx264 -c:a aac -b:a 192k -strict -2 -f flv ${rtmp}
52 | done
53 | done
54 | fi
55 | if [ $watermark = "no" ]
56 | then
57 | echo -e "${yellow} 你选择不添加水印,程序将开始推流. ${font}"
58 | # 循环
59 | while true
60 | do
61 | cd $folder
62 | for video in $(ls *.mp4)
63 | do
64 | ffmpeg -re -i "$video" -c:v copy -c:a aac -b:a 192k -strict -2 -f flv ${rtmp}
65 | done
66 | done
67 | fi
68 | }
69 |
70 | # 停止推流
71 | stream_stop(){
72 | screen -S stream -X quit
73 | killall ffmpeg
74 | }
75 |
76 | # 开始菜单设置
77 | echo -e "${yellow} FFmpeg无人值守循环推流 ${font}"
78 | echo -e "${red} 请确定此脚本是在screen窗口内运行! ${font}"
79 | echo -e "${green} 1.安装FFmpeg ${font}"
80 | echo -e "${green} 2.开始循环推流 ${font}"
81 | echo -e "${green} 3.停止推流 ${font}"
82 | start_menu(){
83 | read -p "请输入数字(1-3),选择你要进行的操作:" num
84 | case "$num" in
85 | 1)
86 | ffmpeg_install
87 | ;;
88 | 2)
89 | stream_start
90 | ;;
91 | 3)
92 | stream_stop
93 | ;;
94 | *)
95 | echo -e "${red} 请输入正确的数字 (1-3) ${font}"
96 | ;;
97 | esac
98 | }
99 |
100 | # 运行开始菜单
101 | start_menu
102 |
--------------------------------------------------------------------------------