Linux installer: remove old init.d files, fix for init.d startup/shutdown script.

This commit is contained in:
Adam Ierymenko 2013-12-16 16:40:03 -08:00
parent b792ab8ff1
commit b54f998a85
3 changed files with 28 additions and 6 deletions

View File

@ -58,7 +58,11 @@ case "$system" in
targ="zt1-${vmajor}_${vminor}_${revision}-linux-${machine}-install" targ="zt1-${vmajor}_${vminor}_${revision}-linux-${machine}-install"
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 gcc -Os -o $targ installer.c ext/lz4/lz4.o ext/lz4/lz4hc.o
fi
strip --strip-all $targ strip --strip-all $targ
ls -l $targ ls -l $targ

View File

@ -47,10 +47,8 @@ fi
running=0 running=0
if [ "$pid" -gt 0 ]; then 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 running=1
else
rm -f "$zthome/zerotier-one.pid"
fi fi
fi fi

View File

@ -45,6 +45,7 @@
#else #else
#include <unistd.h> #include <unistd.h>
#include <pwd.h> #include <pwd.h>
#include <dirent.h>
#include <fcntl.h> #include <fcntl.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -284,9 +285,28 @@ int main(int argc,char **argv)
} }
printf("write %s\n",buf); 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 */ /* Link init script to all the proper places for startup/shutdown */
symlink("/etc/init.d/zerotier-one","/etc/rc0.d/K89zerotier-one"); symlink("/etc/init.d/zerotier-one","/etc/rc0.d/K89zerotier-one");
printf("link /etc/init.d/zerotier-one /etc/rc0.d/K89zerotier-one\n"); 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"); symlink("/etc/init.d/zerotier-one","/etc/rc2.d/S11zerotier-one");
printf("link /etc/init.d/zerotier-one /etc/rc2.d/S11zerotier-one\n"); printf("link /etc/init.d/zerotier-one /etc/rc2.d/S11zerotier-one\n");
symlink("/etc/init.d/zerotier-one","/etc/rc3.d/S11zerotier-one"); 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"); printf("link /etc/init.d/zerotier-one /etc/rc4.d/S11zerotier-one\n");
symlink("/etc/init.d/zerotier-one","/etc/rc5.d/S11zerotier-one"); symlink("/etc/init.d/zerotier-one","/etc/rc5.d/S11zerotier-one");
printf("link /etc/init.d/zerotier-one /etc/rc5.d/S11zerotier-one\n"); printf("link /etc/init.d/zerotier-one /etc/rc5.d/S11zerotier-one\n");
symlink("/etc/init.d/zerotier-one","/etc/rc6.d/S11zerotier-one"); symlink("/etc/init.d/zerotier-one","/etc/rc6.d/K89zerotier-one");
printf("link /etc/init.d/zerotier-one /etc/rc6.d/S11zerotier-one\n"); printf("link /etc/init.d/zerotier-one /etc/rc6.d/K89zerotier-one\n");
#endif #endif
printf("# Done!\n"); printf("# Done!\n");