-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstep4.php
executable file
·226 lines (213 loc) · 8.5 KB
/
step4.php
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
<?php
include_once( '../config.php' );
include_once( INSTALL_PATH.'/Settings.class.php' );
// 設定の保存
$settings = Settings::factory();
$settings->post();
$settings->save();
//EPG取得所要時間の計算
$BS_tuners = (int)$settings->bs_tuners;
$GR_tuners = (int)$settings->gr_tuners;
$CS_flag = $settings->cs_rec_flg!=0 ? TRUE : FALSE;
// XML取り込みは、BS 210sec(atomD525) CS 140sec(仮定)を想定
if( $BS_tuners > 0 ){
if( !$CS_flag ){
$bs_max = 1;
$bs_tim = array( 0, 220 + 15 + 30 ); // BS only
}else{
$bs_max = $BS_tuners>=3 ? 3 : $BS_tuners;
// $bs_tim = array( 0, 950, 890, 890 ); // XML取り込み2並列
$bs_tim = array( 0, 750, 510, 330 ); // XML取り込み2並列
}
}
$gr_rec_tm = FIRST_REC + $settings->rec_switch_time + 1;
$GR_num = count( $GR_CHANNEL_MAP );
if( $BS_tuners ){
$bs_max = $BS_tuners>=3 ? 3 : $BS_tuners;
if( !$CS_flag ){
$shepherd_th_tm = $bs_tim[1];
$getepg_th_tm = 180 + 15;
$getepg_th_xm = 210;
}else{
$shepherd_th_tm = $bs_tim[$bs_max];
$getepg_th_tm = 180 + 15 +( 120 + 15 ) * 2;
$getepg_th_xm = 210 + 140 * 2;
}
}else{
$shepherd_th_tm = 0;
$getepg_th_tm = 0;
$getepg_th_xm = 0;
}
if( $GR_tuners ){
$shepherd_gr_tm = (int)ceil( $GR_num / $GR_tuners ) * $gr_rec_tm;
$getepg_gr_tm = $GR_num * ( 60 + 10 );
}else{
$shepherd_gr_tm = 0;
$getepg_gr_tm = 0;
}
if( $shepherd_th_tm < $shepherd_gr_tm )
$shepherd_th_tm = $shepherd_gr_tm;
$shepherd_th_tm = (int)ceil( $shepherd_th_tm / 60 );
$getepg_th_tm = (int)ceil( ($getepg_th_tm+$getepg_gr_tm) / 60 );
//shepherd.php 所要時間算出
$tmpdrive_size = disk_free_space( "/tmp" );
$gr_bs_para = FALSE;
if( $rec_cmds[PT1_CMD_NUM]['epgTs'] && TUNER_UNIT1>0 ){
$gr_pt1 = $GR_tuners<TUNER_UNIT1? $GR_tuners : TUNER_UNIT1;
$bs_pt1 = $BS_tuners<TUNER_UNIT1? $BS_tuners : TUNER_UNIT1;
}else{
$gr_pt1 = 0;
$bs_pt1 = 0;
}
for( $tuner=0; $tuner<$GR_tuners-TUNER_UNIT1; $tuner++ ){
if( $rec_cmds[$OTHER_TUNERS_CHARA['GR'][$tuner]['reccmd']]['epgTs'] )
$gr_pt1++;
}
for( $tuner=0; $tuner<$BS_tuners-TUNER_UNIT1; $tuner++ ){
if( $rec_cmds[$OTHER_TUNERS_CHARA['BS'][$tuner]['reccmd']]['epgTs'] )
$bs_pt1++;
}
$gr_oth = $GR_tuners - $gr_pt1;
$bs_oth = $BS_tuners - $bs_pt1;
if( $gr_pt1>0 || $bs_pt1>0 ){
if( $gr_oth && $tmpdrive_size<=(GR_OTH_EPG_SIZE+GR_XML_SIZE) || $bs_oth && $tmpdrive_size<=(BS_OTH_EPG_SIZE+BS_XML_SIZE) ){
echo 'step4.php::テンポラリー容量が不十分なためEPG更新が出来ません。空き容量を確保してください。';
exit();
}
$gr_work_size = $gr_oth || $gr_pt1 ? GR_OTH_EPG_SIZE * $gr_oth + GR_PT1_EPG_SIZE * $gr_pt1 + GR_XML_SIZE : 0;
if( $bs_oth ){
$th_work_size = BS_OTH_EPG_SIZE + BS_XML_SIZE;
if( $bs_oth > 1 )
$th_work_size += CS_OTH_EPG_SIZE * ( $bs_oth - 1 );
}else
$th_work_size = 0;
if( $bs_pt1 && $bs_oth < 3 ){
$th_work_size += $bs_oth ? CS_PT1_EPG_SIZE : BS_PT1_EPG_SIZE;
if( 3-$bs_oth > 1 )
$th_work_size += CS_PT1_EPG_SIZE * ( 3 - $bs_oth - 1 );
}
if( $gr_work_size+$th_work_size > $tmpdrive_size ){
$gr_bs_sepa = TRUE;
if( $th_work_size > $tmpdrive_size )
$bs_use = 1;
else
$bs_use = $bs_max<3 ? $bs_max : 3;
$gr_use = $gr_work_size>$tmpdrive_size ? 1 : $GR_tuners;
}else{
$gr_bs_sepa = FALSE;
$gr_use = $GR_tuners;
$bs_use = $bs_max;
}
}else{
$tune_cnts = (int)( $tmpdrive_size / GR_OTH_EPG_SIZE );
if( $tune_cnts == 0 ){
echo 'step4.php::テンポラリー容量が不十分なためEPG更新が出来ません。空き容量を確保してください。';
exit();
}
$bs_tmp = array( 0, 3, 4, 6 );
if( $BS_tuners > 0 ){
if( $tune_cnts < 3 ){
echo 'step4.php::テンポラリー容量が不十分なため衛星波のEPG更新が出来ません。空き容量を確保してください。';
exit();
}else{
if( $tune_cnts == 3 ){
$gr_bs_para = TRUE;
$gr_use = $GR_tuners>3 ? 3 : $GR_tuners;
$bs_use = 1;
echo "step4.php::テンポラリー容量が不十分なため地上波・衛星波並列受信が出来ません。空き容量を確保してください。\n";
}else{
if( $GR_tuners > 0 ){
if( $bs_tmp[$bs_max]+$GR_tuners > $tune_cnts ){
$minimam = 11 * 60;
$bs_use = $bs_max;
for( $bs_stk=$bs_max; $bs_stk>0; $bs_stk-- )
if( $tune_cnts > $bs_tmp[$bs_stk] ){
$temp = abs( $bs_tim[$bs_stk] - (int)ceil( $GR_num / ($tune_cnts-$bs_tmp[$bs_stk]) )*$gr_rec_tm );
if( $minimam >= $temp ){
$minimam = $temp;
$bs_use = $bs_stk;
}
}
$gr_use = $tune_cnts - $bs_tmp[$bs_use];
//所要時間算出
$gr_times = (int)ceil( $GR_num / $gr_use ) * $gr_rec_tm;
$para_tm = $gr_times<$bs_tim[$bs_use] ? $bs_tim[$bs_use] : $gr_times;
//セパレート・モード時の所要時間算出
$gr_use_sepa = $GR_tuners>$tune_cnts ? $tune_cnts : $GR_tuners;
$gr_times = (int)ceil( $GR_num / $gr_use_sepa ) * $gr_rec_tm;
for( $bs_use_sepa=$bs_max; $bs_use_sepa>0; $bs_use_sepa-- )
if( $bs_tmp[$bs_use_sepa] <= $tune_cnts )
break;
$sepa_tm = $gr_times + $bs_tim[$bs_use_sepa];
//地上波・衛星波 分離判定
if( $sepa_tm < $para_tm ){
$gr_bs_para = TRUE;
$gr_use = $gr_use_sepa;
$bs_use = $bs_use_sepa;
}
}else{
$gr_use = $GR_tuners;
$bs_use = $bs_max;
}
}else{
$gr_use = 0;
for( $bs_use=$bs_max; $bs_use>0; $bs_use-- )
if( $bs_tmp[$bs_use] <= $tune_cnts )
break;
}
}
}
}else{
$gr_use = $GR_tuners>$tune_cnts ? $tune_cnts : $GR_tuners;
$bs_use = 0;
}
}
$gr_times = $gr_use ? (int)ceil( $GR_num / $gr_use )*$gr_rec_tm : 0;
if( $gr_bs_para ){
$shepherd_tm = $gr_times + $bs_tim[$bs_use];
}else{
$shepherd_tm = $gr_times>$bs_tim[$bs_use] ? $gr_times : $bs_tim[$bs_use];
}
$shepherd_tm = (int)ceil( $shepherd_tm / 60 );
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>インストール最終ステップ</title>
</head>
<body>
<p>初期設定が完了しました。<br>
下のリンクをクリックするとEPGの初回受信が始まります。初回受信が終了するまで番組表は表示できません。</p>
<p>EPG受信後、/etc/cron.d/以下にcronによる定期EPG受信の自動実行を設定する必要があります。<br>
Debian/Ubuntu用の設定ファイルは<?php echo INSTALL_PATH; ?>/cron.d/shepherdです。<br>
Debian/Ubuntuをお使いの方は<br>
<pre>
$ sudo cp <?php echo INSTALL_PATH; ?>/cron.d/shepherd /etc/cron.d/ [Enter]
</pre>
<br>という具合にコピーするだけで動作するでしょう。ただしhttpdのドキュメントルートが/var/www/以外の場合は、それに合わせた修正が必要です。<br>
それ以外のディストリビューションをお使いの方はDebian/Ubuntu用の設定ファイルを参考に、適切にcronの設定を行ってください。</p>
<p>なお、設定ミスや受信データの異常によってEPGの初回受信に失敗すると番組表の表示はできません。<br>
設定ミスが疑われる場合、<a href="<?php echo $settings->install_url; ?>/install/step1.php">インストール設定</a>を実行し直してください。<br>
また、手動でEPGの受信を試みるのもひとつの方法です。コンソール上で、<br>
<pre>
$ sudo <?php echo INSTALL_PATH; ?>/shepherd.php [Enter]
</pre>
<br>
と実行してください。</p>
<br>
<p>EPGの受信には<?php echo $shepherd_tm; ?>分程度かかります。</p>
<a href="step5.php?time=<?php echo $shepherd_tm; ?>">このリンクをクリックするとEPGの初回受信を開始します。</a>
<p><br><br></p>
<?php if( $gr_oth>0 || $bs_oth>0 ) echo "<p><注意事項><br>
当スクリプトは、全チューナーを総動員してEPG受信を行います。<br>
録画コマンドでEPG用TS出力が出来ない場合は、テンポラリーを大量消費します。<br>
テンポラリーが不足する場合、それに応じて同時受信数を減らしますがEPG取得完了が遅くなります。<br>
テンポラリー容量の目安は、PT2 1枚の場合、地上波のみ340MB・地上波+BS 850MB・地上波+BS+CS 1020MBです。<br>
2枚挿しの場合は地上波のみ680MB・地上波+BS 1190MB・地上波+BS+CS 1700MBとなります。<br>
<br>
現在設定で十分なテンポラリーを確保した環境下での最短受信時間は、$shepherd_th_tm分です。</p>"; ?>
</body>
</html>