Browse Source

next commit

master
0x3F 1 year ago
parent
commit
d233f8258e
10 changed files with 1707 additions and 0 deletions
  1. 26
    0
      Makefile
  2. 5
    0
      comments.txt
  3. 4
    0
      firststart.sh
  4. 0
    0
      forums.c
  5. 0
    0
      forums.h
  6. 99
    0
      forumtest.sh
  7. 2
    0
      serve/index.html
  8. 1518
    0
      server.c
  9. 49
    0
      server.h
  10. 4
    0
      start.sh

+ 26
- 0
Makefile View File

@@ -0,0 +1,26 @@
1
+COMPILENAME = oscillator
2
+
3
+SOURCES = $(wildcard *.c)
4
+
5
+NIXCC = gcc
6
+WINCC = i686-w64-mingw32-gcc
7
+
8
+C_OBJ = $(SOURCES:.o)
9
+
10
+LIBSNIX = -Wl,-Bstatic -lm -lcrypto -lssl -levent -Wl,-Bdynamic -lpthread
11
+LIBSWIN = -lm -mwindows -lcrypto -lssl -levent -lpthread
12
+
13
+COMPILE_FLAGS = -g -Wall -s -O2 -o
14
+#COMPILE_FLAGS = -g -Wall -o
15
+
16
+linux:
17
+	$(NIXCC) $(COMPILE_FLAGS) $(COMPILENAME) $(SOURCES) $(LIBSNIX)
18
+
19
+windows:
20
+	$(WINCC) $(COMPILE_FLAGS) $(COMPILENAME) $(SOURCES) $(LIBSWIN)
21
+
22
+run:
23
+	./$(COMPILENAME)
24
+
25
+clean:
26
+	rm -f *.o, $(COMPILENAME)

+ 5
- 0
comments.txt View File

@@ -0,0 +1,5 @@
1
+|
2
+Default User
3
+Test comment.
4
+Mon Mar 19 22:49:27 2018
5
+0

+ 4
- 0
firststart.sh View File

@@ -0,0 +1,4 @@
1
+#!/bin/sh
2
+echo "First start of the webserver"
3
+service networking restart
4
+./start.sh

+ 0
- 0
forums.c View File


+ 0
- 0
forums.h View File


+ 99
- 0
forumtest.sh View File

@@ -0,0 +1,99 @@
1
+#!/bin/sh
2
+### BEGIN INIT INFO
3
+# Provides:
4
+# Required-Start:    $remote_fs $syslog
5
+# Required-Stop:     $remote_fs $syslog
6
+# Default-Start:     2 3 4 5
7
+# Default-Stop:      0 1 6
8
+# Short-Description: Start daemon at boot time
9
+# Description:       Enable service provided by daemon.
10
+### END INIT INFO
11
+
12
+dir="/home/vertesine/webserver/webforums"
13
+cmd="./forumtest"
14
+user="root"
15
+
16
+name=`basename $0`
17
+pid_file="/var/run/$name.pid"
18
+stdout_log="/var/log/$name.log"
19
+stderr_log="/var/log/$name.err"
20
+
21
+get_pid() {
22
+    cat "$pid_file"
23
+}
24
+
25
+is_running() {
26
+    [ -f "$pid_file" ] && ps -p `get_pid` > /dev/null 2>&1
27
+}
28
+
29
+case "$1" in
30
+    start)
31
+    if is_running; then
32
+        echo "Already started"
33
+    else
34
+        echo "Starting $name"
35
+        cd "$dir"
36
+        if [ -z "$user" ]; then
37
+            sudo $cmd >> "$stdout_log" 2>> "$stderr_log" &
38
+        else
39
+            sudo -u "$user" $cmd >> "$stdout_log" 2>> "$stderr_log" &
40
+        fi
41
+        echo $! > "$pid_file"
42
+        if ! is_running; then
43
+            echo "Unable to start, see $stdout_log and $stderr_log"
44
+            exit 1
45
+        fi
46
+    fi
47
+    ;;
48
+    stop)
49
+    if is_running; then
50
+        echo -n "Stopping $name.."
51
+        kill `get_pid`
52
+        for i in 1 2 3 4 5 6 7 8 9 10
53
+        # for i in `seq 10`
54
+        do
55
+            if ! is_running; then
56
+                break
57
+            fi
58
+
59
+            echo -n "."
60
+            sleep 1
61
+        done
62
+        echo
63
+
64
+        if is_running; then
65
+            echo "Not stopped; may still be shutting down or shutdown may have failed"
66
+            exit 1
67
+        else
68
+            echo "Stopped"
69
+            if [ -f "$pid_file" ]; then
70
+                rm "$pid_file"
71
+            fi
72
+        fi
73
+    else
74
+        echo "Not running"
75
+    fi
76
+    ;;
77
+    restart)
78
+    $0 stop
79
+    if is_running; then
80
+        echo "Unable to stop, will not attempt to start"
81
+        exit 1
82
+    fi
83
+    $0 start
84
+    ;;
85
+    status)
86
+    if is_running; then
87
+        echo "Running"
88
+    else
89
+        echo "Stopped"
90
+        exit 1
91
+    fi
92
+    ;;
93
+    *)
94
+    echo "Usage: $0 {start|stop|restart|status}"
95
+    exit 1
96
+    ;;
97
+esac
98
+
99
+exit 0

+ 2
- 0
serve/index.html View File

@@ -0,0 +1,2 @@
1
+<h1>This is Oscillator v0.9.4</h1>
2
+<center>Hello world</center>

+ 1518
- 0
server.c
File diff suppressed because it is too large
View File


+ 49
- 0
server.h View File

@@ -0,0 +1,49 @@
1
+typedef struct{
2
+	char *username;
3
+	char *comment;
4
+	char *timestamp;
5
+	short isowner;
6
+}Comments;
7
+
8
+typedef struct{
9
+	char *filename;
10
+	char *date;
11
+}FileHistory;
12
+
13
+typedef struct{
14
+	struct evhttp_request *req;
15
+	void *arg;
16
+}ThreadSend;
17
+
18
+typedef struct{
19
+	int used;
20
+	unsigned char *buffer;
21
+	unsigned long length;
22
+	char *filepath;
23
+	char *modifydate;
24
+}Cache;
25
+
26
+#define PORT 9001
27
+
28
+//UPDATE -----> setcap cap_sys_chroot+ep /mnt/storage/HTTPD/oscillator
29
+
30
+//#define PROD 1
31
+#define DEV 1
32
+
33
+
34
+const char *password = "0x3Fisgay";
35
+
36
+void fixspaces(char *string, char *replace);
37
+
38
+int checktype(char *request);
39
+
40
+int hasextension(char *path);
41
+
42
+void respond(struct evhttp_request *req, void *arg);
43
+//void respond(ThreadSend *tsend);
44
+
45
+char *statuspage();
46
+
47
+int main(int argc, char *argv[]);
48
+
49
+unsigned char *readFile(const char *location, unsigned long *sizePtr);

+ 4
- 0
start.sh View File

@@ -0,0 +1,4 @@
1
+#!/bin/sh
2
+until ./oscillator; do
3
+    echo "Server 'forumtest' crashed with exit code $?.  Respawning.." >&2
4
+done

Loading…
Cancel
Save