Skip to content

Commit

Permalink
Update readme. Add pre-built server package back as an option.
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbound committed Apr 15, 2021
1 parent 8068d71 commit d05a174
Show file tree
Hide file tree
Showing 4 changed files with 155 additions and 94 deletions.
8 changes: 1 addition & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,14 @@ GitHub Actions allows you to build and deploy Remotely for free from their cloud
I've created a cross-platform command line tool that can leverage the GitHub Actions REST API to build the project and install it on your private server. This process will also embed your server's URL into the desktop clients, so that they won't need to prompt the end user to enter it.

## Installation Instructions:
- You can find the `Remotely_Server_Installer` CLI tool on the [Releases page](https://github.com/lucent-sea/Remotely/releases).
- You can find the `Remotely_Server_Installer[.exe]` CLI tool on the [Releases page](https://github.com/lucent-sea/Remotely/releases).
- You will download and run it on the server where you'll be hosting Remotely.
- You can choose between installing the pre-built release package, or entering GitHub credentials to build and install a customized server.
- The pre-built package will not have your server's URL embedded in the clients. End users will need to enter it manually.
- If you use the pre-built package, you're done! Otherwise, follow the below steps for using the GitHub Actions integration.
- Fork the repo if you haven't already.
- Go to the Actions tab in your forked repo and make sure you can see the Build workflows.
- Before you can use Actions for the first time, there will be prompt that you must accept on this page.
- If you've already forked the repo, you need to keep your repo updated with mine. This doesn't happen automatically.
- This can be done via the command line if you've cloned your repo locally. Refer to [GitHub's docs](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/syncing-a-fork) on how to do this. Otherwise, see below for how to do it completely through the GitHub website.
- On the GitHub page for your repo, you'll see a message that says, "This branch is ## commits behind lucent-sea:master".
- Click the "Pull request" link next to it.
- On the next page, click the "switching the base" link. Now it's pulling from my repo into yours.
- Create and complete the pull request to update your repo.
- Create a Personal Access Token that the installer will use to authorize with GitHub.
- Located here: https://github.com/settings/tokens
- It needs to have the `repo` scope.
Expand Down
1 change: 1 addition & 0 deletions Server.Installer/Models/CliParams.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class CliParams
public string InstallDirectory { get; set; }
public string Reference { get; set; }
public Uri ServerUrl { get; set; }
public bool? UsePrebuiltPackage { get; set; }
public WebServerType? WebServer { get; set; }
}
}
152 changes: 97 additions & 55 deletions Server.Installer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public static async Task Main(string[] args)
BuildServices();

var elevationDetector = Services.GetRequiredService<IElevationDetector>();
var serverInstaller = Services.GetRequiredService<IServerInstaller>();

if (!elevationDetector.IsElevated())
{
Expand All @@ -50,11 +51,16 @@ public static async Task Main(string[] args)
return;
}

ConsoleHelper.WriteLine("Thank you for trying Remotely! This installer will use your " +
"GitHub credentials to build a customized Remotely package and install it on this server.");
ConsoleHelper.WriteLine("Thank you for trying Remotely! This installer will guide you " +
"through deploying the Remotely server onto this machine.");

ConsoleHelper.WriteLine("There are two ways to create the server files. You can download the pre-built package " +
"from the latest public release, or you can use your GitHub credentials to build a customized package through " +
"an integration with GitHub Actions. The pre-built packages will not have your server's URL embedded in the " +
"desktop clients, and end users will need to type it in manually.");

ConsoleHelper.WriteLine("You will need to enter a GitHub Personal Access Token, which will " +
"allow this app to access your fork of the Remotely repo. You can generate a PAT at " +
ConsoleHelper.WriteLine("If using GitHub Actions, you will need to enter a GitHub Personal Access Token, " +
"which will allow this app to access your fork of the Remotely repo. You can generate a PAT at " +
"https://github.com/settings/tokens. You need to give it the \"repo\" scope.");

ConsoleHelper.WriteLine("Be sure to retain your GitHub Personal Access Token if you want to re-use it " +
Expand All @@ -64,21 +70,16 @@ public static async Task Main(string[] args)
"and enable them. If not, this process will fail.");


while (string.IsNullOrWhiteSpace(cliParams.GitHubUsername))
{
cliParams.GitHubUsername = ConsoleHelper.ReadLine("Enter your GitHub username").Trim();
}

while (string.IsNullOrWhiteSpace(cliParams.GitHubPat))
while (cliParams.UsePrebuiltPackage is null)
{
cliParams.GitHubPat = ConsoleHelper.ReadLine("Enter your GitHub Personal Access Token").Trim();
}
ConsoleHelper.WriteLine("Download pre-built package? If false, a customized server package will be created " +
"through GitHub Actions.");

while (string.IsNullOrWhiteSpace(cliParams.Reference))
{
ConsoleHelper.WriteLine("Enter the GitHub branch or tag name from which to build. For example, you can enter " +
" \"master\" to build the latest changes from the default branch. Or you can enter a release tag like \"v2021.04.13.1604\".");
cliParams.Reference = ConsoleHelper.ReadLine("Input Reference").Trim();
var createNew = ConsoleHelper.ReadLine("Selection (true/false)").Trim();
if (bool.TryParse(createNew, out var result))
{
cliParams.CreateNew = result;
}
}

while (string.IsNullOrWhiteSpace(cliParams.InstallDirectory))
Expand All @@ -93,18 +94,6 @@ public static async Task Main(string[] args)
{
cliParams.ServerUrl = serverUrl;
}

}

while (cliParams.CreateNew is null)
{
ConsoleHelper.WriteLine("Create new build? True/false. If false, the latest existing build artifact on GitHub will be used.");

var createNew = ConsoleHelper.ReadLine("Selection").Trim();
if (bool.TryParse(createNew, out var result))
{
cliParams.CreateNew = result;
}
}

while (cliParams.WebServer is null)
Expand All @@ -123,12 +112,49 @@ public static async Task Main(string[] args)
}
}

ConsoleHelper.WriteLine($"Performing server install. GitHub User: {cliParams.GitHubUsername}. " +
$"Server URL: {cliParams.ServerUrl}. Installation Directory: {cliParams.InstallDirectory}. " +
$"Web Server: {cliParams.WebServer}. Create New Build: {cliParams.CreateNew}. " +
$"Git Reference: {cliParams.Reference}");

var serverInstaller = Services.GetRequiredService<IServerInstaller>();
if (cliParams.UsePrebuiltPackage == false)
{
while (string.IsNullOrWhiteSpace(cliParams.GitHubUsername))
{
cliParams.GitHubUsername = ConsoleHelper.ReadLine("Enter your GitHub username").Trim();
}

while (string.IsNullOrWhiteSpace(cliParams.GitHubPat))
{
cliParams.GitHubPat = ConsoleHelper.ReadLine("Enter your GitHub Personal Access Token").Trim();
}

while (string.IsNullOrWhiteSpace(cliParams.Reference))
{
ConsoleHelper.WriteLine("Enter the GitHub branch or tag name from which to build. For example, you can enter " +
" \"master\" to build the latest changes from the default branch. Or you can enter a release tag like \"v2021.04.13.1604\".");
cliParams.Reference = ConsoleHelper.ReadLine("Input Reference").Trim();
}


while (cliParams.CreateNew is null)
{
ConsoleHelper.WriteLine("Create new build? True/false. If false, the latest existing build artifact on GitHub will be used.");

var createNew = ConsoleHelper.ReadLine("Selection").Trim();
if (bool.TryParse(createNew, out var result))
{
cliParams.CreateNew = result;
}
}

ConsoleHelper.WriteLine($"Performing server install. GitHub User: {cliParams.GitHubUsername}. " +
$"Server URL: {cliParams.ServerUrl}. Installation Directory: {cliParams.InstallDirectory}. " +
$"Web Server: {cliParams.WebServer}. Create New Build: {cliParams.CreateNew}. " +
$"Git Reference: {cliParams.Reference}");
}
else
{
ConsoleHelper.WriteLine($"Server URL: {cliParams.ServerUrl}. " +
$"Installation Directory: {cliParams.InstallDirectory}. Web Server: {cliParams.WebServer}.");
}

await serverInstaller.PerformInstall(cliParams);

ConsoleHelper.WriteLine("Installation completed.");
Expand Down Expand Up @@ -177,14 +203,29 @@ private static bool ParseCliParams(string[] args, out CliParams cliParams)

switch (key)
{
case "--github-username":
case "-u":
cliParams.GitHubUsername = value;
continue;
case "--github-pat":
case "-p":
cliParams.GitHubPat = value;
continue;
case "--use-prebuilt":
case "-b":
{
if (bool.TryParse(value, out var result))
{
cliParams.UsePrebuiltPackage = result;
continue;
}
ConsoleHelper.WriteError("--use-prebuilt parameter is invalid. Must be true or false.");
return false;
}
case "--web-server":
case "-w":
{
if (int.TryParse(value, out var webServerResult))
{
cliParams.WebServer = (WebServerType)webServerResult;
continue;
}
ConsoleHelper.WriteError($"--web-server parameter is invalid. Must be a " +
$"number (0 - {Enum.GetValues<WebServerType>().Length}).");
return false;
}
case "--server-url":
case "-s":
{
Expand All @@ -200,6 +241,14 @@ private static bool ParseCliParams(string[] args, out CliParams cliParams)
case "-i":
cliParams.InstallDirectory = value;
continue;
case "--github-username":
case "-u":
cliParams.GitHubUsername = value;
continue;
case "--github-pat":
case "-p":
cliParams.GitHubPat = value;
continue;
case "--reference":
case "-r":
cliParams.Reference = value;
Expand All @@ -215,18 +264,6 @@ private static bool ParseCliParams(string[] args, out CliParams cliParams)
ConsoleHelper.WriteError("--create-new parameter is invalid. Must be true or false.");
return false;
}
case "--web-server":
case "-w":
{
if (int.TryParse(value, out var webServerResult))
{
cliParams.WebServer = (WebServerType)webServerResult;
continue;
}
ConsoleHelper.WriteError($"--web-server parameter is invalid. Must be a " +
$"number (0 - {Enum.GetValues<WebServerType>().Length}).");
return false;
}
default:
return false;
}
Expand All @@ -251,6 +288,10 @@ private static void ShowHelpText()

ConsoleHelper.WriteLine("\tNo Parameters - Run the installer interactively.", 2);

ConsoleHelper.WriteLine("\t--use-prebuilt, -b True/false. Whether to use the pre-built server package from the " +
"latest public release, or to create a customized package through GitHub Actions. The pre-built package " +
"will not contain your server's URL in the desktop clients, and end users will need to type it in manually.", 1);

ConsoleHelper.WriteLine("\t--github-username, -u Your GitHub username, where the forked Remotely repo exists.", 1);

ConsoleHelper.WriteLine("\t--github-pat, -p The GitHub Personal Access Token to use for authentication. " +
Expand All @@ -272,7 +313,8 @@ private static void ShowHelpText()
"requests to the Remotely server. Select the appropriate option for your operating system and web server. " +
"0 = Caddy on Ubuntu. 1 = Nginx on Ubuntu. 2 = Caddy on CentOS. 3 = Nginx on CentOS. 4 = IIS on Windows Server 2016+.", 1);

ConsoleHelper.WriteLine("Example: sudo ./Remotely_Server_Installer -u lucent-sea -p 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 -s https://app.remotely.one -i /var/www/remotely/ -r master -c true -w 0");
ConsoleHelper.WriteLine("Example: sudo ./Remotely_Server_Installer -b false -u lucent-sea -p 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 -s https://app.remotely.one -i /var/www/remotely/ -r master -c true -w 0");
ConsoleHelper.WriteLine("Example: sudo ./Remotely_Server_Installer -b true -s https://app.remotely.one -i /var/www/remotely/ -w 0");
}
}
}
Loading

0 comments on commit d05a174

Please sign in to comment.