• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqt誰得windowscocoapythonphprubygameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwittertestdomvb.netdirectxbtronarduinopreviewerゲームエンジン

Commit MetaInfo

Revision47327c169339b2d2262b9b629b2ce84d0ba55317 (tree)
Zeit2022-04-01 10:30:42
AutorSatoshi Yasuda <7m3tjz@jarl...>
CommiterSatoshi Yasuda

Log Message

modified: dmonitor_utils.c
modified: main.c
modified: repeater_mon.c
modified: repeater_mon.h

Ändern Zusammenfassung

Diff

--- a/debian/changelog
+++ b/debian/changelog
@@ -3,7 +3,7 @@ dmonitor (01.74) unstable; urgency=low
33 * update Closes: (#134)
44 * added os check
55
6- -- Satoshi Yasuda <7m3tjz@jarl.com> Thu, 31 Mar 2022 20:30:00 +0900
6+ -- Satoshi Yasuda <7m3tjz@jarl.com> Thu, 31 Mar 2022 23:00:00 +0900
77
88 dmonitor (01.73) unstable; urgency=low
99
--- a/dmonitor_utils.c
+++ b/dmonitor_utils.c
@@ -1009,3 +1009,27 @@ void invalid_os (void)
10091009 ret = system (cmd);
10101010 }
10111011
1012+void right_os (void)
1013+{
1014+ struct stat sb;
1015+ int i;
1016+ int ret;
1017+ FILE *error_fd;
1018+
1019+ if (stat ("/var/tmp/", &sb)) return;
1020+ if ((sb.st_mode & S_IFMT) != S_IFDIR) return;
1021+ error_fd = fopen (ERROR_TEMP, "w");
1022+ fprintf (error_fd, "<!DOCTYPE HTML>\n");
1023+ fprintf (error_fd, "<html><head>\n");
1024+ fprintf (error_fd, "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n");
1025+ fprintf (error_fd, "<script type=\"text/javascript\">\n");
1026+ fprintf (error_fd, "</script>\n");
1027+ fprintf (error_fd, "</head>\n");
1028+ fprintf (error_fd, "<body style=\"background-color:#ff8c00;\">\n");
1029+ fprintf (error_fd, "<center></center>");
1030+ fprintf (error_fd, "</body></html>");
1031+ fclose (error_fd);
1032+ sprintf (cmd, "/var/www/cgi-bin/file_check %s %s", ERROR_TEMP, ERROR_MSG);
1033+ ret = system (cmd);
1034+}
1035+
--- a/main.c
+++ b/main.c
@@ -46,6 +46,8 @@ void lcd_write (void);
4646 void ntpdate(void);
4747 void dvap_reopen(void);
4848 void invalid_os (void);
49+void right_os (void);
50+
4951 time_t send_time;
5052 unsigned char *ppp;
5153 struct timeval rig_send_time_20mSec;
@@ -141,7 +143,7 @@ int main(int argc, char *argv[])
141143 }
142144 while (fgets (pg_path, sizeof(pg_path), os_release_file))
143145 {
144- //syslog (LOG_INFO, "%s", pg_path);
146+ syslog (LOG_INFO, "%s", pg_path);
145147 if (!memcmp (pg_path, "VERSION_CODENAME=buster", 23)) goto os_ok;
146148 }
147149 fclose (os_release_file);
@@ -149,6 +151,7 @@ int main(int argc, char *argv[])
149151 return -1;
150152 os_ok:
151153 fclose (os_release_file);
154+ right_os ();
152155
153156 dmonitor_file = fopen (DMONITOR_FILE, "r");
154157 if (dmonitor_file == NULL)
--- a/repeater_mon.c
+++ b/repeater_mon.c
@@ -287,6 +287,62 @@ void down_msg (void)
287287 sprintf (temp, "/var/www/cgi-bin/file_check %s %s", MON_HTML_TEMP, MON_HTML);
288288 ret = system (temp);
289289 }
290+
291+void invalid_os (void)
292+{
293+ int ret;
294+ char temp[256];
295+
296+ html_fd = fopen (MON_HTML_TEMP, "w");
297+ html_active_fd = fopen (ACTIVE_HTML_TEMP, "w");
298+ conn_fd = fopen (CONN_TEMP, "w");
299+ fprintf (html_fd, "\n<!DOCTYPE html>\n\n");
300+ fprintf (html_fd, "<html>\n");
301+ fprintf (html_fd, "<head>\n");
302+ fprintf (html_fd, "<title>Multi Forward running Repeater</title>\n");
303+ fprintf (html_fd, "<meta charset=\"UTF-8\">\n");
304+ //fprintf (html_fd, "<meta http-equiv=\"Pragma\" content=\"no-cache\">\n");
305+ //fprintf (html_fd, "<meta http-equiv=\"Cache-Control\" content=\"no-cache\">\n");
306+ //fprintf (html_fd, "<meta name=\"expires\" content=\"0\">\n");
307+ fprintf (html_fd, "</head>\n");
308+ fprintf (html_fd, "<BODY style=\"background-color:#ffffcc;\">\n");
309+ fprintf (html_fd, "<center>\n");
310+ fprintf (html_fd, "<font size=+2>\n");
311+ fprintf (html_fd, "サポートされていないOSです<br>\n");
312+ fprintf (html_fd, "</font>\n</center>\n</body>\n</html>\n\n");
313+ fclose (html_fd);
314+ memset (temp, 0x00, sizeof(temp));
315+ sprintf (temp, "/var/www/cgi-bin/file_check %s %s", MON_HTML_TEMP, MON_HTML);
316+ ret = system (temp);
317+}
318+
319+void right_os (void)
320+{
321+ int ret;
322+ char temp[256];
323+
324+ html_fd = fopen (MON_HTML_TEMP, "w");
325+ html_active_fd = fopen (ACTIVE_HTML_TEMP, "w");
326+ conn_fd = fopen (CONN_TEMP, "w");
327+ fprintf (html_fd, "\n<!DOCTYPE html>\n\n");
328+ fprintf (html_fd, "<html>\n");
329+ fprintf (html_fd, "<head>\n");
330+ fprintf (html_fd, "<title>Multi Forward running Repeater</title>\n");
331+ fprintf (html_fd, "<meta charset=\"UTF-8\">\n");
332+ //fprintf (html_fd, "<meta http-equiv=\"Pragma\" content=\"no-cache\">\n");
333+ //fprintf (html_fd, "<meta http-equiv=\"Cache-Control\" content=\"no-cache\">\n");
334+ //fprintf (html_fd, "<meta name=\"expires\" content=\"0\">\n");
335+ fprintf (html_fd, "</head>\n");
336+ fprintf (html_fd, "<BODY style=\"background-color:#ffffcc;\">\n");
337+ fprintf (html_fd, "<center>\n");
338+ fprintf (html_fd, "<font size=+2>\n");
339+ fprintf (html_fd, "<br>\n");
340+ fprintf (html_fd, "</font>\n</center>\n</body>\n</html>\n\n");
341+ fclose (html_fd);
342+ memset (temp, 0x00, sizeof(temp));
343+ sprintf (temp, "/var/www/cgi-bin/file_check %s %s", MON_HTML_TEMP, MON_HTML);
344+ ret = system (temp);
345+}
290346
291347 void main(int argc, char** argv)
292348 {
@@ -303,11 +359,29 @@ void main(int argc, char** argv)
303359 int ret;
304360 int p_cnt;
305361 char last_mod[32];
362+ FILE *os_release_file;
306363
307364 json_length = 0;
308365 json_cnt = 0;
309366 repeater_cnt = 0;
310367
368+ os_release_file = fopen (OS_RELEASE, "r");
369+ if (os_release_file == NULL)
370+ {
371+ invalid_os ();
372+ return;
373+ }
374+ while (fgets (buff, 256, os_release_file))
375+ {
376+ if (!memcmp (buff, "VERSION_CODENAME=buster", 23)) goto os_ok;
377+ }
378+ fclose (os_release_file);
379+ invalid_os ();
380+ return;
381+os_ok:
382+ fclose (os_release_file);
383+ //right_os ();
384+
311385 memset (last_mod, 0x20, 32);
312386 last_mod_fd = fopen (LAST_MODIFIED_FILE, "r");
313387 if (last_mod_fd)
--- a/repeater_mon.h
+++ b/repeater_mon.h
@@ -28,6 +28,9 @@
2828 #define CONN_TXT "/var/tmp/repeater_conn.txt"
2929 #define DMONITOR_FILE "/var/www/dmonitor.conf"
3030
31+#define OS_RELEASE "/etc/os-release"
32+#define CODENAME "buster"
33+
3134 #define TRUE 1
3235 #define FALSE 0
3336