-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.c
35 lines (31 loc) · 825 Bytes
/
install.c
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
#include <stdio.h>
#include <dirent.h>
#include <unistd.h>
#include <string.h>
int main(int argc, char *argv[]) {
char dir[PATH_MAX];
getcwd(dir, PATH_MAX);
char *tmp = "/cgi.service";
strcat(dir, tmp);
FILE * file = fopen(dir, "w+");
if (!file) {
printf("Can't create .service file.\n");
}
getcwd(dir, PATH_MAX);
fprintf(file, "[Unit]\n"
"Description=my cgi service.\n"
"\n"
"[Service]\n"
"Type=forking\n"
"EnvironmentFile=%s/config\n"
"ExecStart=/usr/local/bin/cgi $ARG1 $ARG2 %s\n"
"ExecStop=/usr/local/bin/cgi stop %s\n"
"\n"
"[Install]\n"
"WantedBy=multi-user.target\n",
dir, dir, dir);
fclose(file);
//printf("Server installed successully.\n"
// "To change default configurations(host, port) see config file at %s/config.\n", dir);
return 0;
}