mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-06 12:33:44 +02:00
Mac installer works now.
This commit is contained in:
parent
42ed37b385
commit
77683eda0c
1 changed files with 16 additions and 10 deletions
26
installer.c
26
installer.c
|
@ -98,7 +98,11 @@
|
||||||
|
|
||||||
static unsigned char *_unlz4(const void *lz4,int decompressedLen)
|
static unsigned char *_unlz4(const void *lz4,int decompressedLen)
|
||||||
{
|
{
|
||||||
unsigned char *buf = (unsigned char *)malloc(decompressedLen);
|
unsigned char *buf;
|
||||||
|
|
||||||
|
if (!decompressedLen)
|
||||||
|
return (unsigned char *)0;
|
||||||
|
buf = (unsigned char *)malloc(decompressedLen);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
return (unsigned char *)0;
|
return (unsigned char *)0;
|
||||||
if (LZ4_decompress_fast((const char *)lz4,(char *)buf,decompressedLen) <= 0) {
|
if (LZ4_decompress_fast((const char *)lz4,(char *)buf,decompressedLen) <= 0) {
|
||||||
|
@ -111,7 +115,7 @@ static unsigned char *_unlz4(const void *lz4,int decompressedLen)
|
||||||
static int _putBlob(const void *lz4,int decompressedLen,const char *path,int executable,int protect,int preserveOwnership)
|
static int _putBlob(const void *lz4,int decompressedLen,const char *path,int executable,int protect,int preserveOwnership)
|
||||||
{
|
{
|
||||||
unsigned char *data = _unlz4(lz4,decompressedLen);
|
unsigned char *data = _unlz4(lz4,decompressedLen);
|
||||||
if (!data)
|
if ((!data)&&(decompressedLen))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
#ifdef __WINDOWS__
|
#ifdef __WINDOWS__
|
||||||
|
@ -128,7 +132,7 @@ static int _putBlob(const void *lz4,int decompressedLen,const char *path,int exe
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fwrite(data,decompressedLen,1,f) != 1) {
|
if ((decompressedLen)&&(fwrite(data,decompressedLen,1,f) != 1)) {
|
||||||
fclose(f);
|
fclose(f);
|
||||||
free(data);
|
free(data);
|
||||||
#ifdef __WINDOWS__
|
#ifdef __WINDOWS__
|
||||||
|
@ -170,6 +174,7 @@ int _tmain(int argc, _TCHAR* argv[])
|
||||||
int main(int argc,char **argv)
|
int main(int argc,char **argv)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
/* Installer/updater for Unix-like systems (including Mac) */
|
||||||
#ifdef __UNIX_LIKE__ /******************************************************/
|
#ifdef __UNIX_LIKE__ /******************************************************/
|
||||||
|
|
||||||
char buf[4096];
|
char buf[4096];
|
||||||
|
@ -189,7 +194,7 @@ int main(int argc,char **argv)
|
||||||
chown("/Library/Application Support/ZeroTier",0,0);
|
chown("/Library/Application Support/ZeroTier",0,0);
|
||||||
printf("mkdir /Library/Application Support/ZeroTier\n");
|
printf("mkdir /Library/Application Support/ZeroTier\n");
|
||||||
mkdir(zthome = "/Library/Application Support/ZeroTier/One",0755);
|
mkdir(zthome = "/Library/Application Support/ZeroTier/One",0755);
|
||||||
#else
|
#else /* not Apple */
|
||||||
mkdir("/var/lib",0755);
|
mkdir("/var/lib",0755);
|
||||||
printf("mkdir /var/lib\n");
|
printf("mkdir /var/lib\n");
|
||||||
mkdir(zthome = "/var/lib/zerotier-one",0755);
|
mkdir(zthome = "/var/lib/zerotier-one",0755);
|
||||||
|
@ -216,7 +221,7 @@ int main(int argc,char **argv)
|
||||||
sprintf(buf,"%s/launch.sh",zthome);
|
sprintf(buf,"%s/launch.sh",zthome);
|
||||||
if (!putBlob(mac__launch_sh,buf,1,0,0)) { printf("! unable to write %s\n",buf); return 1; } printf("write %s\n",buf);
|
if (!putBlob(mac__launch_sh,buf,1,0,0)) { printf("! unable to write %s\n",buf); return 1; } printf("write %s\n",buf);
|
||||||
|
|
||||||
/* Add mac to launchd */
|
/* Add ZT1 task to Apple's launchd */
|
||||||
sprintf(buf,"/Library/LaunchDaemons/com.zerotier.one.plist");
|
sprintf(buf,"/Library/LaunchDaemons/com.zerotier.one.plist");
|
||||||
if (!putBlob(mac__com_zerotier_one_plist,buf,0,0,0)) { printf("! unable to write %s\n",buf); return 1; } printf("write %s\n",buf);
|
if (!putBlob(mac__com_zerotier_one_plist,buf,0,0,0)) { printf("! unable to write %s\n",buf); return 1; } printf("write %s\n",buf);
|
||||||
|
|
||||||
|
@ -252,8 +257,8 @@ int main(int argc,char **argv)
|
||||||
sprintf(buf,"/Applications/ZeroTier One.app/Contents/Resources/zt1icon.icns");
|
sprintf(buf,"/Applications/ZeroTier One.app/Contents/Resources/zt1icon.icns");
|
||||||
if (!putBlob(mac_ui__contents_resources_zt1icon_icns,buf,1,0,0)) { printf("! unable to write %s\n",buf); return 1; } printf("write %s\n",buf);
|
if (!putBlob(mac_ui__contents_resources_zt1icon_icns,buf,1,0,0)) { printf("! unable to write %s\n",buf); return 1; } printf("write %s\n",buf);
|
||||||
|
|
||||||
/* Load script into launchctl, start ZeroTier One */
|
/* Load script into running launchd, start ZeroTier One */
|
||||||
printf("exec launchctl load /Library/LaunchDaemons/com.zerotier.one.plist"); fflush(stdout);
|
printf("exec launchctl load /Library/LaunchDaemons/com.zerotier.one.plist: "); fflush(stdout);
|
||||||
long launchctlpid = (long)vfork();
|
long launchctlpid = (long)vfork();
|
||||||
if (launchctlpid == 0) {
|
if (launchctlpid == 0) {
|
||||||
execl("/bin/launchctl","/bin/launchctl","load","/Library/LaunchDaemons/com.zerotier.one.plist",(char *)0);
|
execl("/bin/launchctl","/bin/launchctl","load","/Library/LaunchDaemons/com.zerotier.one.plist",(char *)0);
|
||||||
|
@ -264,8 +269,8 @@ int main(int argc,char **argv)
|
||||||
int exitcode = 0;
|
int exitcode = 0;
|
||||||
waitpid(launchctlpid,&exitcode,0);
|
waitpid(launchctlpid,&exitcode,0);
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("installed.\n");
|
||||||
#endif
|
#endif /* __APPLE__ */
|
||||||
|
|
||||||
#ifdef __LINUX__
|
#ifdef __LINUX__
|
||||||
/* Write Linux init script */
|
/* Write Linux init script */
|
||||||
|
@ -304,7 +309,7 @@ int main(int argc,char **argv)
|
||||||
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/K89zerotier-one");
|
symlink("/etc/init.d/zerotier-one","/etc/rc6.d/K89zerotier-one");
|
||||||
printf("link /etc/init.d/zerotier-one /etc/rc6.d/K89zerotier-one\n");
|
printf("link /etc/init.d/zerotier-one /etc/rc6.d/K89zerotier-one\n");
|
||||||
#endif
|
#endif /* __LINUX__ */
|
||||||
|
|
||||||
printf("# Done!\n");
|
printf("# Done!\n");
|
||||||
|
|
||||||
|
@ -318,6 +323,7 @@ int main(int argc,char **argv)
|
||||||
|
|
||||||
#endif /* __UNIX_LIKE__ ****************************************************/
|
#endif /* __UNIX_LIKE__ ****************************************************/
|
||||||
|
|
||||||
|
/* Installer/updater for Windows systems */
|
||||||
#ifdef __WINDOWS__ /********************************************************/
|
#ifdef __WINDOWS__ /********************************************************/
|
||||||
|
|
||||||
#endif /* __WINDOWS__ ******************************************************/
|
#endif /* __WINDOWS__ ******************************************************/
|
||||||
|
|
Loading…
Add table
Reference in a new issue