mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2024-12-19 04:57:53 +00:00
Linux installer: remove old init.d files, fix for init.d startup/shutdown script.
This commit is contained in:
parent
b792ab8ff1
commit
b54f998a85
@ -58,7 +58,11 @@ case "$system" in
|
||||
|
||||
targ="zt1-${vmajor}_${vminor}_${revision}-linux-${machine}-install"
|
||||
|
||||
gcc -Os -o $targ installer.c ext/lz4/lz4.o ext/lz4/lz4hc.o
|
||||
if [ -e /usr/bin/clang ]; then
|
||||
clang -Os -o $targ installer.c ext/lz4/lz4.o ext/lz4/lz4hc.o
|
||||
else
|
||||
gcc -Os -o $targ installer.c ext/lz4/lz4.o ext/lz4/lz4hc.o
|
||||
fi
|
||||
strip --strip-all $targ
|
||||
ls -l $targ
|
||||
|
||||
|
@ -47,10 +47,8 @@ fi
|
||||
|
||||
running=0
|
||||
if [ "$pid" -gt 0 ]; then
|
||||
if [ "`readlink -nf /proc/$pid/exe`" = "$zthome/zerotier-one" ]; then
|
||||
if [ -n "`ls -l /proc/$pid/exe | grep -F zerotier-one`" ]; then
|
||||
running=1
|
||||
else
|
||||
rm -f "$zthome/zerotier-one.pid"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
24
installer.c
24
installer.c
@ -45,6 +45,7 @@
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#include <pwd.h>
|
||||
#include <dirent.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
@ -284,9 +285,28 @@ int main(int argc,char **argv)
|
||||
}
|
||||
printf("write %s\n",buf);
|
||||
|
||||
/* Erase any previous startup/shutdown links */
|
||||
for(int rl=0;rl<=6;++rl) {
|
||||
sprintf(buf,"/etc/rc%d.d",rl);
|
||||
DIR *rcd = opendir(buf);
|
||||
if (rcd) {
|
||||
struct dirent *d;
|
||||
while ((d = readdir(rcd))) {
|
||||
if (strstr(d->d_name,"zerotier-one")) {
|
||||
sprintf(buf,"/etc/rc%d.d/%s",rl,d->d_name);
|
||||
unlink(buf);
|
||||
printf("rm %s\n",buf);
|
||||
}
|
||||
}
|
||||
closedir(rcd);
|
||||
}
|
||||
}
|
||||
|
||||
/* Link init script to all the proper places for startup/shutdown */
|
||||
symlink("/etc/init.d/zerotier-one","/etc/rc0.d/K89zerotier-one");
|
||||
printf("link /etc/init.d/zerotier-one /etc/rc0.d/K89zerotier-one\n");
|
||||
symlink("/etc/init.d/zerotier-one","/etc/rc1.d/K89zerotier-one");
|
||||
printf("link /etc/init.d/zerotier-one /etc/rc1.d/K89zerotier-one\n");
|
||||
symlink("/etc/init.d/zerotier-one","/etc/rc2.d/S11zerotier-one");
|
||||
printf("link /etc/init.d/zerotier-one /etc/rc2.d/S11zerotier-one\n");
|
||||
symlink("/etc/init.d/zerotier-one","/etc/rc3.d/S11zerotier-one");
|
||||
@ -295,8 +315,8 @@ int main(int argc,char **argv)
|
||||
printf("link /etc/init.d/zerotier-one /etc/rc4.d/S11zerotier-one\n");
|
||||
symlink("/etc/init.d/zerotier-one","/etc/rc5.d/S11zerotier-one");
|
||||
printf("link /etc/init.d/zerotier-one /etc/rc5.d/S11zerotier-one\n");
|
||||
symlink("/etc/init.d/zerotier-one","/etc/rc6.d/S11zerotier-one");
|
||||
printf("link /etc/init.d/zerotier-one /etc/rc6.d/S11zerotier-one\n");
|
||||
symlink("/etc/init.d/zerotier-one","/etc/rc6.d/K89zerotier-one");
|
||||
printf("link /etc/init.d/zerotier-one /etc/rc6.d/K89zerotier-one\n");
|
||||
#endif
|
||||
|
||||
printf("# Done!\n");
|
||||
|
Loading…
Reference in New Issue
Block a user