mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-02-20 17:52:46 +00:00
Installer work...
This commit is contained in:
parent
9c4d5f8bb2
commit
5179dfafbe
@ -62,8 +62,7 @@
|
|||||||
|
|
||||||
// Linux init.d script
|
// Linux init.d script
|
||||||
#ifdef __LINUX__
|
#ifdef __LINUX__
|
||||||
#include "installer-build/redhat__init_d__zerotier_one.c"
|
#include "installer-build/init_d__zerotier_one.c"
|
||||||
#include "installer-build/debian__init_d__zerotier_one.c"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Apple Tap device driver
|
// Apple Tap device driver
|
||||||
@ -99,6 +98,11 @@ static bool _instFile(const void *lz4,int decompressedLen,const char *path)
|
|||||||
unsigned char *data = unlzr(lz4,decompressedLen);
|
unsigned char *data = unlzr(lz4,decompressedLen);
|
||||||
if (!data)
|
if (!data)
|
||||||
return false;
|
return false;
|
||||||
|
#ifdef __WINDOWS__
|
||||||
|
DeleteFileA(path);
|
||||||
|
#else
|
||||||
|
unlink(path);
|
||||||
|
#endif
|
||||||
FILE *f = fopen(path,"w");
|
FILE *f = fopen(path,"w");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
delete [] data;
|
delete [] data;
|
||||||
@ -107,7 +111,11 @@ static bool _instFile(const void *lz4,int decompressedLen,const char *path)
|
|||||||
if (fwrite(data,decompressedLen,1,f) != 1) {
|
if (fwrite(data,decompressedLen,1,f) != 1) {
|
||||||
fclose(f);
|
fclose(f);
|
||||||
delete [] data;
|
delete [] data;
|
||||||
Utils::rm(path);
|
#ifdef __WINDOWS__
|
||||||
|
DeleteFileA(path);
|
||||||
|
#else
|
||||||
|
unlink(path);
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
fclose(f);
|
fclose(f);
|
||||||
@ -134,11 +142,14 @@ int main(int argc,char **argv)
|
|||||||
const char *zthome;
|
const char *zthome;
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
mkdir("/Library/Application Support/ZeroTier",0755);
|
mkdir("/Library/Application Support/ZeroTier",0755);
|
||||||
|
chmod("/Library/Application Support/ZeroTier",0755);
|
||||||
|
chown("/Library/Application Support/ZeroTier",0,0);
|
||||||
mkdir(zthome = "/Library/Application Support/ZeroTier/One",0755);
|
mkdir(zthome = "/Library/Application Support/ZeroTier/One",0755);
|
||||||
#else
|
#else
|
||||||
mkdir("/var/lib",0755);
|
mkdir("/var/lib",0755);
|
||||||
mkdir(zthome = "/var/lib/zerotier-one",0755);
|
mkdir(zthome = "/var/lib/zerotier-one",0755);
|
||||||
#endif
|
#endif
|
||||||
|
chmod(zthome,0755);
|
||||||
chown(zthome,0,0);
|
chown(zthome,0,0);
|
||||||
|
|
||||||
sprintf(buf,"%s/zerotier-one",zthome);
|
sprintf(buf,"%s/zerotier-one",zthome);
|
||||||
@ -146,7 +157,7 @@ int main(int argc,char **argv)
|
|||||||
fprintf(stderr,"Unable to write %s\n",buf);
|
fprintf(stderr,"Unable to write %s\n",buf);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
chmod(buf,0700);
|
chmod(buf,0755);
|
||||||
chown(buf,0,0);
|
chown(buf,0,0);
|
||||||
fprintf(stdout,"%s\n",buf);
|
fprintf(stdout,"%s\n",buf);
|
||||||
|
|
||||||
@ -191,27 +202,20 @@ int main(int argc,char **argv)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __LINUX__
|
#ifdef __LINUX__
|
||||||
struct stat st;
|
sprintf(buf,"/etc/init.d/zerotier-one");
|
||||||
if (stat("/etc/redhat-release",&st) == 0) {
|
if (!instFile(init_d__zerotier_one,buf)) {
|
||||||
// Redhat-derived distribution
|
fprintf(stderr,"Unable to write %s\n",buf);
|
||||||
sprintf(buf,"/etc/init.d/zerotier-one");
|
return 1;
|
||||||
if (!instFile(redhat__init_d__zerotier_one,buf)) {
|
|
||||||
fprintf(stderr,"Unable to write %s\n",buf);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
chmod(buf,0755);
|
|
||||||
fprintf(stdout,"%s (version for RedHat-derived distros)\n",buf);
|
|
||||||
}
|
|
||||||
if (stat("/etc/debian_version",&st) == 0) {
|
|
||||||
// Debian-derived distribution
|
|
||||||
sprintf(buf,"/etc/init.d/zerotier-one");
|
|
||||||
if (!instFile(debian__init_d__zerotier_one,buf)) {
|
|
||||||
fprintf(stderr,"Unable to write %s\n",buf);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
chmod(buf,0755);
|
|
||||||
fprintf(stdout,"%s (version for Debian-derived distros)\n",buf);
|
|
||||||
}
|
}
|
||||||
|
chown(buf,0,0);
|
||||||
|
chmod(buf,0755);
|
||||||
|
fprintf(stdout,"%s\n",buf);
|
||||||
|
|
||||||
|
symlink("/etc/init.d/zerotier-one","/etc/rc0.d/K89zerotier-one");
|
||||||
|
symlink("/etc/init.d/zerotier-one","/etc/rc2.d/S11zerotier-one");
|
||||||
|
symlink("/etc/init.d/zerotier-one","/etc/rc3.d/S11zerotier-one");
|
||||||
|
symlink("/etc/init.d/zerotier-one","/etc/rc4.d/S11zerotier-one");
|
||||||
|
symlink("/etc/init.d/zerotier-one","/etc/rc5.d/S11zerotier-one");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // __UNIX_LIKE__
|
#endif // __UNIX_LIKE__
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#
|
#
|
||||||
# zerotier-one Virtual distributed Ethernet service
|
# zerotier-one Virtual distributed Ethernet service
|
||||||
#
|
#
|
||||||
# chkconfig: 2345 90 60
|
# chkconfig: 2345 11 89
|
||||||
# description: ZeroTier One provides public and private distributed ethernet \
|
# description: ZeroTier One provides public and private distributed ethernet \
|
||||||
# networks. See https://www.zerotier.com/ for more information.
|
# networks. See https://www.zerotier.com/ for more information.
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user