Skip to content

Commit

Permalink
OSX supported
Browse files Browse the repository at this point in the history
  • Loading branch information
starek4 committed Jan 8, 2018
1 parent a18f733 commit 9c87a3a
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 17 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ All x64 distributions with **bash**, **uname** and **shutdown** command.<br />
**Install instructions**: Unzip downloaded file and run install.sh script.<br />
**Run client**: fly -l \<login\>

### OSX x64
macOS Sierra and higher<br />
**Install instructions**: Unzip downloaded file and run install.sh script.<br />
**Run client as root**: sudo fly -l \<login\>

### Android
Android Lollipop (API 21) or higher.

Expand Down
51 changes: 36 additions & 15 deletions client/FlyUnix/Makefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,46 @@
# Publish and pack application
# Publish and pack application for linux-x64 and osx-x64

PUBLISH_PATH=bin/Release/netcoreapp2.0/linux-x64/publish
PUBLISH_PATH_LINUX=bin/Release/netcoreapp2.0/linux-x64/publish
PUBLISH_PATH_OSX=bin/Release/netcoreapp2.0/osx-x64/publish
LINUX_ARCHIVE=fly_linux64.zip
OSX_ARCHIVE=fly_osx64.zip

pack: publish
cp scripts/install.sh ${PUBLISH_PATH}
cp scripts/uninstall.sh ${PUBLISH_PATH}
cd ${PUBLISH_PATH} && zip fly.zip *
cp ${PUBLISH_PATH}/fly.zip .
pack: pack_linux pack_osx

publish: clean
# Linux
pack_linux: publish_linux
cp scripts/linux-x64/install.sh ${PUBLISH_PATH_LINUX}
cp scripts/linux-x64/uninstall.sh ${PUBLISH_PATH_LINUX}
cd ${PUBLISH_PATH_LINUX} && zip ${LINUX_ARCHIVE} *
cp ${PUBLISH_PATH_LINUX}/${LINUX_ARCHIVE} .

publish_linux: clean
dotnet restore
dotnet publish -c Release -r linux-x64

test_linux: pack_linux
mkdir test
cp ${LINUX_ARCHIVE} test/
cd test && unzip ${LINUX_ARCHIVE}


# OSX
pack_osx: publish_osx
cp scripts/osx-x64/install.sh ${PUBLISH_PATH_OSX}
cp scripts/osx-x64/uninstall.sh ${PUBLISH_PATH_OSX}
cd ${PUBLISH_PATH_OSX} && zip ${OSX_ARCHIVE} *
cp ${PUBLISH_PATH_OSX}/${OSX_ARCHIVE} .

publish_osx: clean
dotnet restore
dotnet publish -c Release -r osx-x64



clean:
$(RM) fly.zip
$(RM) ${LINUX_ARCHIVE}
$(RM) ${OSX_ARCHIVE}
$(RM) -rf bin obj
$(RM) -rf test

test: pack
mkdir test
cp fly.zip test/
cd test && unzip fly.zip

.PHONY: publish pack
.PHONY: publish_linux pack_linux publish_osx pack_osx pack
9 changes: 8 additions & 1 deletion client/FlyUnix/ShellHandler.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
using System.Diagnostics;
using Shared.Enviroment;

namespace FlyUnix
{
Expand Down Expand Up @@ -36,7 +38,12 @@ public static string GetDeviceName()

public static void Shutdown()
{
ExecuteBashCommand("shutdown -h");
if (EnviromentHelper.GetPlatformType() == PlatformType.Linux)
ExecuteBashCommand("shutdown -h");
else if (EnviromentHelper.GetPlatformType() == PlatformType.Osx)
ExecuteBashCommand("sudo shutdown -h +1");
else
throw new NotImplementedException("This system is not supported.");
}
}
}
File renamed without changes.
File renamed without changes.
21 changes: 21 additions & 0 deletions client/FlyUnix/scripts/osx-x64/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh
# Script for installing fly client

ID=`id -u`

# Checkf if we have needed privileges
if test "$ID" -ne "0"
then
echo "Please run this script as root"
exit 1
fi

rm -rf /usr/local/fly 2> /dev/null
rm /usr/local/bin/fly 2> /dev/null

mkdir /usr/local/fly
cp -rp * /usr/local/fly/
ln -s /usr/local/fly/FlyUnix /usr/local/bin/fly
echo "Fly client is installed..."
echo "If you will have any problems with fly client, check prerequisites for running .NET Core apps at:"
echo "https://docs.microsoft.com/en-us/dotnet/core/linux-prerequisites?tabs=netcore2x"
16 changes: 16 additions & 0 deletions client/FlyUnix/scripts/osx-x64/uninstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh
# Script for installing fly client

ID=`id -u`

# Checkf if we have needed privileges
if test "$ID" -ne "0"
then
echo "Please run this script as root"
exit 1
fi

rm -rf /usr/local/fly 2> /dev/null
rm /usr/local/bin/fly 2> /dev/null

echo "Fly client is now uninstalled..."
6 changes: 5 additions & 1 deletion client/Shared/Enviroment/EnviromentHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ namespace Shared.Enviroment
{
public static class EnviromentHelper
{
private static PlatformType GetPlatformType()
public static PlatformType GetPlatformType()
{
if (RuntimeInformation.FrameworkDescription.Contains("Mono"))
return PlatformType.Phone;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
return PlatformType.Windows;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
return PlatformType.Linux;
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
return PlatformType.Osx;
return PlatformType.Unknown;
}

Expand All @@ -26,6 +28,8 @@ public static ILogger GetLogger()
return new LinuxLogger();
case PlatformType.Windows:
return new WindowsLogger();
case PlatformType.Osx:
return new LinuxLogger();
case PlatformType.Phone:
return null;
default:
Expand Down
1 change: 1 addition & 0 deletions client/Shared/Enviroment/PlatformType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ public enum PlatformType
{
Windows,
Linux,
Osx,
Phone,
Unknown
}
Expand Down

0 comments on commit 9c87a3a

Please sign in to comment.