diff --git a/.gitignore.txt b/.gitignore.txt
new file mode 100644
index 0000000..530f53c
--- /dev/null
+++ b/.gitignore.txt
@@ -0,0 +1,2 @@
+easyWSL\bin
+easyWSL\obj
\ No newline at end of file
diff --git a/.vs/easyWSL/v16/.suo b/.vs/easyWSL/v16/.suo
new file mode 100644
index 0000000..5d94ff0
Binary files /dev/null and b/.vs/easyWSL/v16/.suo differ
diff --git a/LICENSE b/LICENSE
index fdddb29..722136a 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,24 +1,38 @@
-This is free and unencumbered software released into the public domain.
-
-Anyone is free to copy, modify, publish, use, compile, sell, or
-distribute this software, either in source code form or as a compiled
-binary, for any purpose, commercial or non-commercial, and by any
-means.
-
-In jurisdictions that recognize copyright laws, the author or authors
-of this software dedicate any and all copyright interest in the
-software to the public domain. We make this dedication for the benefit
-of the public at large and to the detriment of our heirs and
-successors. We intend this dedication to be an overt act of
-relinquishment in perpetuity of all present and future rights to this
-software under copyright law.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
-OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-
-For more information, please refer to
+# easyWSL
+
+Copyright (c) 2020 RedCode-Labs and Jakub Wróbel
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+# bsdtar
+
+All of the C source code and documentation in this package is subject
+to the following:
+
+Copyright (c) 2003-2006 Tim Kientzle
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer
+ in this position and unchanged.
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/README.md b/README.md
index 08888d0..5c80655 100644
--- a/README.md
+++ b/README.md
@@ -6,16 +6,22 @@
- Create custom WSL distros and manage them easily
+ Create WSL distros based on Docker Images.
-## Instructions
+> Made with ❤ by @wrobeljakub and @redcode-labs team.
-1. Clone and go to the dir. of this repository.
- 1. `git clone https://github.com/Unrooted/easyWSL`
- 2. `cd easyWSL`
-2. Change the post-installation script already. Use commands dependent on the container of your choice.
-3. Run Powershell script as an administrator.
-4. Click `Yes` and install Docker, continuing with the installation instructions from the .exe
-5. Your system needs to be rebooted. After a reboot, the script will continue to run.
-6. After the script is done, everything is done! Feel free and enjoy your Docker-container-based WSL distro!
+## What does this project do?
+
+There's a script inside which downloads a .tar or .tar.gz image from Docker Hub. In fact, it can be more than just one .tar/.tar.gz, that's why bsdtar.exe is included in this repo, because it is responsible for 'merging' all .tar/.tar.gz files together. Then, one big .tar/.tar.gz is created (if it's needed, we don't have to do this thing if the image contains just one layer) and can be easily exported as a WSL distro.
+
+## How to use it?
+
+Just go to our release page, download latest release and just run it. Done!
+
+## Command List
+
+`--help` / `-h` -> list all available commands
+`--name` / `-n` -> name for your distro
+`--distro` / `-d` -> id of the distro in the sources.json file
+`--path` / `-p` -> path where you want to place your .vhd (it's basically how WSL distros work, they're .tar/.tar.gz files turned into .vhd with Linux filesystems)
\ No newline at end of file
diff --git a/easyWSL.png b/easyWSL.png
index 9e6c47c..61a42af 100644
Binary files a/easyWSL.png and b/easyWSL.png differ
diff --git a/easyWSL.ps1 b/easyWSL.ps1
deleted file mode 100644
index 3e968f2..0000000
--- a/easyWSL.ps1
+++ /dev/null
@@ -1,209 +0,0 @@
-Import-Module PSWorkflow
-function Show-Menu {
- Clear-Host
- Write-Host " _ _______ __ "
- Write-Host " ___ ____ ________ _| | / / ___// / "
- Write-Host " / _ \/ __ `/ ___/ / / / | /| / /\__ \/ / "
- Write-Host " / __/ /_/ (__ ) /_/ /| |/ |/ /___/ / /___"
- Write-Host " \___/\__,_/____/\__, / |__/|__//____/_____/"
- Write-Host " /____/ "
-
- Write-Host "1: Install Distro"
- Write-Host "2: Show currently installed distros"
- Write-Host "3: Unregister Distro"
- Write-Host "H: Help"
- Write-Host "Q: Quit"
-}
-
-Show-Menu
-$selection = Read-Host "Choose what you want to do"
-switch ($selection) {
-
- "1" {
- $DistroName = Read-Host "Name of your distro"
- if ($DistroName) {
- Write-Host "You've choosen [$DistroName] as the name for your distro"
- } else {
- Write-Warning -Message "No name input."
- }
- $DockerContainer = Read-Host "Docker Hub repo name (for example: archlinux:latest)"
- if ($DockerContainer) {
- Write-Host "You've choosen [$DockerContainer] as your Docker container"
- } else {
- Write-Warning -Message "No Docker container name input."
- }
- }
-
- "2" {
- wsl.exe -l -v
- }
-
- "3" {
- wsl.exe -l
- Read-Host "Name of your distro that you want to unregister"
- if ($UnregisterDistro) {
- Write-Host "You've choosen [$UnregisterDistro] as the name for your distro"
- } else {
- Write-Warning -Message "No name input."
- }
- }
-
- "H" {
- Start-Process "https://github.com/redcode-labs/easyWSL/blob/master/README.md"
- exit
- }
-
- "q" {
- exit
- }
- "Q" {
- exit
- }
- default {
- Write-Host "Not a correct command"
- Show-Menu
- $selection = Read-Host "Choose what you want to do"
- switch ($selection) {
-
- "1" {
- $DistroName = Read-Host "Name of your distro"
- if ($DistroName) {
- Write-Host "You've choosen [$DistroName] as the name for your distro"
- } else {
- Write-Warning -Message "No name input."
- }
- $DockerContainer = Read-Host "Docker Hub repo name (for example: archlinux:latest)"
- if ($DockerContainer) {
- Write-Host "You've choosen [$DockerContainer] as your Docker container"
- } else {
- Write-Warning -Message "No Docker container name input."
- }
- }
-
- "2" {
- wsl.exe -l -v
- }
-
- "3" {
- wsl.exe -l
- Read-Host "Name of your distro that you want to unregister"
- if ($UnregisterDistro) {
- Write-Host "You've choosen [$UnregisterDistro] as the name for your distro"
- } else {
- Write-Warning -Message "No name input."
- }
- }
-
- "H" {
- Start-Process "https://github.com/redcode-labs/easyWSL/blob/master/README.md"
- exit
- }
-
- "q" {
- exit
- }
- "Q" {
- exit
- }
- default {
- exit
- }
- }
- }
-}
-function ChooseInstallationDirectory {
- do
- {
- $script:DistroInstallationDirectory = Read-Host -Prompt "Type the path to directory where you want to store all your custom made distros "
- if (($script:DistroInstallationDirectory.Substring($script:DistroInstallationDirectory.Length-1) -eq "\")) {
- $script:DistroInstallationDirectory = $script:DistroInstallationDirectory.Substring(0,$script:DistroInstallationDirectory.Length-1)
- }
-
- $script:DistroDir = $script:DistroInstallationDirectory+"\"+$script:DistroName
- if (-Not (Test-Path -Path $script:DistroInstallationDirectory)) {write-Host "This is not a correct path!"}
- } while (-Not (Test-Path -Path $script:DistroInstallationDirectory))
-
-}
-
-
-ChooseInstallationDirectory
-
-
-$confirmation = Read-Host "Are you sure you want to install" $DistroName "to path" $DistroDir "[y/n]"
-while($confirmation -eq "n")
-{
- if ($confirmation -eq 'y') {break}
- ChooseInstallationDirectory
- $confirmation = Read-Host "Are you sure you want to install" $DistroName "to path" $DistroDir"? [y/n]"
-}
-
-$confirmation = Read-Host "Do you want to set" $DistroName "as a default wsl distro? [y/n]"
-if ($confirmation -eq 'y') {
- $DefaultDistro = "true"
-}
-else {
- $DefaultDistro = "false"
-}
-
-
-$DockerWingetPackageName = "Docker.DockerDesktop"
-$DockerContainerLocal = "wsl"+$DistroName
-$DockerExportTarName = "install.tar"
-
-
-workflow Install-easyWSL {
- param (
- $DockerWingetPackageName,
- $DistroInstallationDirectory,
- $DistroName,
- $DockerExportTarName,
- $DistroDir,
- $DockerContainerLocal,
- $DockerContainer
- )
-
- Set-ExecutionPolicy Unrestricted
-
- # check if Docker is installed on a machine, if not install it
- if (-Not (Get-Command docker -errorAction SilentlyContinue))
- {
- if (Get-Command winget -errorAction SilentlyContinue)
- {
- winget install -e --id Docker.DockerDesktop
- } else {
- Invoke-WebRequest -Uri "https://desktop.docker.com/win/stable/Docker%20Desktop%20Installer.exe" -OutFile $env:USERPROFILE"\Downloads"
- Start-Process -Wait "c:\Users\$env:USERNAME\Downloads\Docker Desktop Installer.exe"
- }
- }
-
- # ask user to confirm rebooting machine
- $confirmation = Read-Host "Your computer will have to be rebooted. Are you ready to do that now? [y/n]"
- do
- {
- if (-Not ($confirmation -eq 'y')) {
- $confirmation = Read-Host "Maybe now? [y/n]"
- }
- } while($confirmation -eq "n")
-
- Restart-Computer -Wait
-
- # create a directory for the distribution inside a user specified directory
- New-Item -Path $DistroInstallationDirectory -Name $DistroName -ItemType "directory"
-
- # run the docker container with a chosen distro and extract the rootfs to the .tar file located in a distribution directory
- docker run -it --name $DockerContainerLocal $DockerContainer
- docker export --output=$DistroDir+"\"+$DockerExportTarName $DockerContainerLocal
-
- # register the distribution in wsl
- wsl.exe --import $DistroName $DistroDir $DistroDir+"\"+$DockerExportTarName
-
- #set the distro default in wsl if the user specified that he want do it
- if($DefaultDistro -eq "true") {
- wsl.exe --set-default $DistroName
- }
-
- # post setup, linux commands in here are specified to be for Arch-based systems
- wsl.exe --distro $DistroName "pacman -Syu -y && pacman -S sudo -y && pacman -S vim -y && echo export EDITOR=/usr/bin/vim >> ~/.bashrc && pwconv && grpconv && chmod 0744 /etc/shadow && chmod 0744 /etc/gshadow && exit"
-}
-
-Install-easyWSL $DockerWingetPackageName $DistroInstallationDirectory $DistroName $DockerExportTarName $DistroDir $DockerContainerLocal $DockerContainer
\ No newline at end of file
diff --git a/easyWSL.sln b/easyWSL.sln
new file mode 100644
index 0000000..924375c
--- /dev/null
+++ b/easyWSL.sln
@@ -0,0 +1,37 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.30804.86
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "easyWSL", "easyWSL\easyWSL.csproj", "{7B9B61FA-2500-40CD-A3AC-08C7C67832B6}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|Any CPU = Release|Any CPU
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {7B9B61FA-2500-40CD-A3AC-08C7C67832B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {7B9B61FA-2500-40CD-A3AC-08C7C67832B6}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {7B9B61FA-2500-40CD-A3AC-08C7C67832B6}.Debug|x64.ActiveCfg = Debug|x64
+ {7B9B61FA-2500-40CD-A3AC-08C7C67832B6}.Debug|x64.Build.0 = Debug|x64
+ {7B9B61FA-2500-40CD-A3AC-08C7C67832B6}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {7B9B61FA-2500-40CD-A3AC-08C7C67832B6}.Debug|x86.Build.0 = Debug|Any CPU
+ {7B9B61FA-2500-40CD-A3AC-08C7C67832B6}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {7B9B61FA-2500-40CD-A3AC-08C7C67832B6}.Release|Any CPU.Build.0 = Release|Any CPU
+ {7B9B61FA-2500-40CD-A3AC-08C7C67832B6}.Release|x64.ActiveCfg = Release|x64
+ {7B9B61FA-2500-40CD-A3AC-08C7C67832B6}.Release|x64.Build.0 = Release|x64
+ {7B9B61FA-2500-40CD-A3AC-08C7C67832B6}.Release|x86.ActiveCfg = Release|Any CPU
+ {7B9B61FA-2500-40CD-A3AC-08C7C67832B6}.Release|x86.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {0E034EA1-614B-4CCB-AD51-9DC2A3CE510C}
+ EndGlobalSection
+EndGlobal
diff --git a/easyWSL/App.config b/easyWSL/App.config
new file mode 100644
index 0000000..56efbc7
--- /dev/null
+++ b/easyWSL/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/easyWSL/DistroInstaller.cs b/easyWSL/DistroInstaller.cs
new file mode 100644
index 0000000..b768bd4
--- /dev/null
+++ b/easyWSL/DistroInstaller.cs
@@ -0,0 +1,155 @@
+using System;
+using System.Net;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Text.Json;
+using System.IO;
+using System.Threading.Tasks;
+using System.Diagnostics;
+using System.Threading;
+
+namespace easyWSL
+{
+ class DistroInstaller
+ {
+ public class TokenFromResponse
+ {
+ public string token { get; set; }
+ public string access_token { get; set; }
+
+ public int expires_in { get; set; }
+
+ public string issued_at { get; set; }
+
+ }
+
+
+ public static void InstallDistro(string distroID, string distroName, string distroPath, string easyWSLDataDirectory, string easyWSLDirectory)
+ {
+
+ void StartProcessSilently(string processName, string processArguments)
+ {
+ ProcessStartInfo psi = new ProcessStartInfo();
+ psi.FileName = processName;
+ psi.UseShellExecute = false;
+ psi.RedirectStandardError = true;
+ psi.RedirectStandardOutput = true;
+ psi.Arguments = processArguments;
+
+ Process proc = Process.Start(psi);
+ proc.WaitForExit();
+ }
+
+ string GetRequest(string url)
+ {
+ HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
+ HttpWebResponse response = (HttpWebResponse)request.GetResponse();
+ request.Credentials = CredentialCache.DefaultCredentials;
+ Stream receiveStream = response.GetResponseStream();
+ StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8);
+ string responseStream = readStream.ReadToEnd();
+ response.Close();
+ readStream.Close();
+ return responseStream;
+ }
+
+ void GetRequestWithHeaderToFile(string url, string token, string type, string fileName)
+ {
+ HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
+ request.Headers.Add("Authorization", "Bearer " + token);
+ request.Accept = type;
+ HttpWebResponse response = (HttpWebResponse)request.GetResponse();
+ Stream receiveStream = response.GetResponseStream();
+ int bufferSize = 1024, bytesRead = 0;
+ byte[] buffer = new byte[bufferSize];
+
+ FileStream fileStream = File.Create(fileName);
+ while((bytesRead = receiveStream.Read(buffer, 0, bufferSize)) != 0)
+ {
+ fileStream.Write(buffer, 0, bytesRead);
+ }
+
+ response.Close();
+ fileStream.Close();
+ }
+
+
+ SortedDictionary sources = JsonSerializer.Deserialize>(File.ReadAllText("sources.json"), new JsonSerializerOptions { PropertyNameCaseInsensitive = true });
+ string repository = "", tag = "", registry = "registry-1.docker.io", authorizationUrl = "https://auth.docker.io/token", registryUrl = "registry.docker.io";
+
+ if (sources[distroID].Image.Contains('/'))
+ {
+ string[] imageArray = sources[distroID].Image.Split('/');
+ tag = "latest";
+ repository = sources[distroID].Image;
+ }
+
+ else
+ {
+ string[] imageArray = sources[distroID].Image.Split(':');
+ string imgage = imageArray[0];
+ tag = imageArray[1];
+ repository = $"library/{imgage}";
+ }
+
+
+ dynamic tokenFromResponse = JsonSerializer.Deserialize(GetRequest($"{authorizationUrl}?service={registryUrl}&scope=repository:{repository}:pull"));
+
+ string layersDirectory = $"{easyWSLDataDirectory}\\layers";
+ Directory.CreateDirectory(layersDirectory);
+
+ string concatTarCommand = $" cf {layersDirectory}\\install.tar";
+
+ int count = 0;
+ foreach (string layer in sources[distroID].Layers)
+ {
+ count++;
+ Console.WriteLine($"Downloading {count}. layer ...");
+
+ tokenFromResponse = JsonSerializer.Deserialize(GetRequest($"{authorizationUrl}?service={registryUrl}&scope=repository:{repository}:pull"));
+
+ string layerName = $"layer{count}.tar.bz";
+ string layerPath = $"{layersDirectory}\\{layerName}";
+
+ GetRequestWithHeaderToFile($"https://{registry}/v2/{repository}/blobs/{layer}", tokenFromResponse.token, "application/vnd.docker.distribution.manifest.v2+json", layerPath);
+ concatTarCommand += $" @{layerPath} ";
+ }
+
+
+ Console.WriteLine("Creating install.tar file ...");
+ if(sources[distroID].Layers.Count == 1)
+ {
+ File.Move($"{layersDirectory}\\layer1.tar.bz", $"{layersDirectory}\\install.tar.bz");
+
+ Console.WriteLine("Registering the distro ...");
+ StartProcessSilently("wsl.exe", $"--import {distroName} {distroPath} {easyWSLDataDirectory}\\layers\\install.tar.bz");
+ }
+ else
+ {
+ StartProcessSilently($"{easyWSLDirectory}\\dep\\bsdtar.exe", concatTarCommand);
+
+ Console.WriteLine("Registering the distro ...");
+ StartProcessSilently("wsl.exe", $"--import {distroName} {distroPath} {easyWSLDataDirectory}\\layers\\install.tar");
+ }
+
+
+ Console.WriteLine("Cleaning up ...");
+ Directory.Delete(layersDirectory, true);
+
+ Console.Write($"Do you want to start {distroName} distribution? [Y/n]:");
+ ConsoleKeyInfo chooseToStart = Console.ReadKey();
+ do
+ {
+ if ((chooseToStart.Key == ConsoleKey.Y) ^ (chooseToStart.Key == ConsoleKey.Enter))
+ Process.Start("wsl.exe", $"-d {distroName}");
+
+
+ else if (chooseToStart.Key == ConsoleKey.N)
+ Environment.Exit(0);
+ } while ((chooseToStart.Key != ConsoleKey.Y) & (chooseToStart.Key != ConsoleKey.Enter) & (chooseToStart.Key != ConsoleKey.N));
+
+
+ }
+ }
+}
diff --git a/easyWSL/Program.cs b/easyWSL/Program.cs
new file mode 100644
index 0000000..d38a982
--- /dev/null
+++ b/easyWSL/Program.cs
@@ -0,0 +1,130 @@
+using System;
+using System.IO;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Text.Json;
+using System.Text.Json.Serialization;
+using System.Threading;
+using System.Collections.Specialized;
+using System.Text.RegularExpressions;
+using System.Diagnostics;
+
+namespace easyWSL
+{
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ if(args.Length == 0)
+ {
+ Console.ForegroundColor = ConsoleColor.Red;
+ Console.WriteLine(" _ _______ __ ");
+ Console.WriteLine(" ___ ____ ________ _| | / / ___// / ");
+ Console.WriteLine(" / _ \\/ __ `/ ___/ / / / | /| / /\\__ \\/ / ");
+ Console.WriteLine(" / __/ /_/ (__ ) /_/ /| |/ |/ /___/ / /___");
+ Console.WriteLine(" \\___/\\__,_/____/\\__, / |__/|__//____/_____/");
+ Console.WriteLine(" /____/ ");
+ Console.WriteLine(" ");
+ Console.ResetColor();
+ }
+
+ SortedDictionary sources = JsonSerializer.Deserialize>(File.ReadAllText("sources.json"), new JsonSerializerOptions { PropertyNameCaseInsensitive = true });
+
+ string distroID = "", distroName = "", distroPath = "";
+ int distroNumber;
+
+ bool isConversionSuccessful;
+
+ string easyWSLDirectory = (Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase)).Remove(0, 6);
+ string easyWSLDataDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "easyWSL");
+
+ string distrosDirectory = $"{easyWSLDataDirectory}\\distros";
+ Directory.CreateDirectory(distrosDirectory);
+
+ if (args.Length >= 2)
+ {
+ foreach (int argument in Enumerable.Range(0, args.Length))
+ {
+ if ((args[argument] == "-d") ^ (args[argument] == "--distro"))
+ {
+ distroID = args[argument + 1];
+ }
+
+ else if ((args[argument] == "-n") ^ (args[argument] == "--name"))
+ {
+ distroName = args[argument + 1];
+ }
+
+ else if ((args[argument] == "-p") ^ (args[argument] == "--path"))
+ {
+ distroID = args[argument + 1];
+ }
+ }
+ }
+
+ if (distroID == "")
+ {
+ int count = 1;
+ foreach (KeyValuePair kvp in sources)
+ {
+ Console.WriteLine($"{count}. {sources[kvp.Key].Name}");
+ count++;
+ }
+
+ do
+ {
+ Console.Write("A number of a distro you want to install: ");
+
+ isConversionSuccessful = Int32.TryParse(Console.ReadLine(), out distroNumber);
+ } while ((distroNumber > sources.Count) ^ (isConversionSuccessful == false));
+
+
+
+ count = 1;
+ foreach (KeyValuePair kvp in sources)
+ {
+ distroID = kvp.Key;
+ count++;
+ if (count > distroNumber)
+ break;
+ }
+ }
+
+ if(distroName == "")
+ {
+ Console.Write("A name for your distro (default " + sources[distroID].Name + "): ");
+ distroName = Console.ReadLine();
+
+ if (distroName == "")
+ {
+ distroName = sources[distroID].Name;
+ }
+
+ distroName = Regex.Replace(distroName, @"\s+", "");
+ }
+
+ if( Directory.Exists(distroPath) == false)
+ {
+
+ do
+ {
+ Console.Write("A path to a directory where you want to store your distro (default is " + distrosDirectory + "\\" + distroName + "): ");
+ distroPath = Console.ReadLine();
+ } while((Directory.Exists(distroPath) == false) ^ (distroPath == ""));
+
+
+ if(distroPath == "")
+ {
+ distroPath = distrosDirectory + "\\" + distroName;
+ }
+ }
+
+
+ Directory.CreateDirectory(distroPath);
+
+ DistroInstaller.InstallDistro(distroID, distroName, distroPath, easyWSLDataDirectory, easyWSLDirectory);
+ }
+ }
+}
diff --git a/easyWSL/Properties/AssemblyInfo.cs b/easyWSL/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..a160bae
--- /dev/null
+++ b/easyWSL/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("easyWSL")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("easyWSL")]
+[assembly: AssemblyCopyright("Copyright © 2021")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("7b9b61fa-2500-40cd-a3ac-08c7c67832b6")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/easyWSL/Sources.cs b/easyWSL/Sources.cs
new file mode 100644
index 0000000..b837b6f
--- /dev/null
+++ b/easyWSL/Sources.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace easyWSL
+{
+ class Sources
+ {
+ public string Name { get; set; }
+ public string Image { get; set; }
+ public List Layers { get; set; }
+ }
+}
diff --git a/easyWSL/dep/bsdtar.exe b/easyWSL/dep/bsdtar.exe
new file mode 100644
index 0000000..31d70f5
Binary files /dev/null and b/easyWSL/dep/bsdtar.exe differ
diff --git a/easyWSL/dep/bzip2.dll b/easyWSL/dep/bzip2.dll
new file mode 100644
index 0000000..8174912
Binary files /dev/null and b/easyWSL/dep/bzip2.dll differ
diff --git a/easyWSL/dep/libarchive2.dll b/easyWSL/dep/libarchive2.dll
new file mode 100644
index 0000000..30b8cf9
Binary files /dev/null and b/easyWSL/dep/libarchive2.dll differ
diff --git a/easyWSL/dep/zlib1.dll b/easyWSL/dep/zlib1.dll
new file mode 100644
index 0000000..076f503
Binary files /dev/null and b/easyWSL/dep/zlib1.dll differ
diff --git a/easyWSL/easyWSL.csproj b/easyWSL/easyWSL.csproj
new file mode 100644
index 0000000..a049f18
--- /dev/null
+++ b/easyWSL/easyWSL.csproj
@@ -0,0 +1,101 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {7B9B61FA-2500-40CD-A3AC-08C7C67832B6}
+ Exe
+ easyWSL
+ easyWSL
+ v4.7.2
+ 512
+ true
+ true
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+ true
+ bin\x64\Debug\
+ DEBUG;TRACE
+ full
+ x64
+ 7.3
+ prompt
+ true
+
+
+ bin\x64\Release\
+ TRACE
+ true
+ pdbonly
+ x64
+ 7.3
+ prompt
+ true
+
+
+ easyWSL.ico
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Always
+
+
+
+
+
+ Always
+
+
+ Always
+
+
+ Always
+
+
+ Always
+
+
+
+
\ No newline at end of file
diff --git a/easyWSL/easyWSL.ico b/easyWSL/easyWSL.ico
new file mode 100644
index 0000000..3264dec
Binary files /dev/null and b/easyWSL/easyWSL.ico differ
diff --git a/easyWSL/sources.json b/easyWSL/sources.json
new file mode 100644
index 0000000..90cc60a
--- /dev/null
+++ b/easyWSL/sources.json
@@ -0,0 +1,101 @@
+{
+ "archlinux": {
+ "name": "ArchLinux",
+ "image": "archlinux:latest",
+ "layers": [ "sha256:cc7ff1c0e7225a03b06669026f98576552c6c608efd4474485532e681f67c58c", "sha256:503b62125c985d32e9a8faef48d50c978b9415c11cc0763b740f0d468f64ff97" ]
+ },
+
+ "ubuntu20.04": {
+ "name": "Ubuntu 20.04",
+ "image": "ubuntu:20.04",
+ "layers": [ "sha256:da7391352a9bb76b292a568c066aa4c3cbae8d494e6a3c68e3c596d34f7c75f8", "sha256:14428a6d4bcdba49a64127900a0691fb00a3f329aced25eb77e3b65646638f8d", "sha256:2c2d948710f21ad82dce71743b1654b45acb5c059cf5c19da491582cef6f2601" ]
+ },
+
+ "ubuntu20.10": {
+ "name": "Ubuntu 20.10",
+ "image": "ubuntu:20.10",
+ "layers": [ "sha256:d8b994c442864dd519627740d3a4d134f385a2caa54b7f59bf9d372adcf7def0", "sha256:b0773f3f14174f9bc8047861c64c2aa0cc581e73b16b48194a2884ad3918d01b", "sha256:5b20aefff2dc282ec6e2f496acce5b228bd1dfc30057a8ed41eae0513191b312" ]
+ },
+
+ "alpine": {
+ "name": "Alpine",
+ "image": "alpine:latest",
+ "layers": [ "sha256:801bfaa63ef2094d770c809815b9e2b9c1194728e5e754ef7bc764030e140cea" ]
+ },
+
+ "debianstable": {
+ "name": "DebianStable",
+ "image": "debian:stable",
+ "layers": [ "sha256:5e0d4a82136cf43df758ea4260c3aba2203db5ed27b727940a7e2b7cfd6af580" ]
+ },
+
+ "debianunstable": {
+ "name": "DebianUnstable",
+ "image": "debian:unstable",
+ "layers": [ "sha256:38f54f0c57a31d9522970c134a72491612f81faaf99832d75020d1ad121d3b9c" ]
+ },
+
+ "debiantesting": {
+ "name": "DebianTesting",
+ "image": "debian:testing",
+ "layers": [ "sha256:ecd924c7226f314c16de965258f37da4aa990c07e494be1116af512706138401" ]
+ },
+
+ "centos": {
+ "name": "CentOS",
+ "image": "centos:latest",
+ "layers": [ "sha256:7a0437f04f83f084b7ed68ad9c4a4947e12fc4e1b006b38129bac89114ec3621" ]
+ },
+
+ "clearlinux": {
+ "name": "Clear Linux",
+ "image": "clearlinux:latest",
+ "layers": [ "sha256:d3ff7f519c930e7e7f52e7a9b42e4235f38349a56d0d604ed64660fae08f30c4" ]
+ },
+
+ "fedora": {
+ "name": "Fedora",
+ "image": "fedora:latest",
+ "layers": [ "sha256:ae7b613df528a37664448affa6e52ff405701cda015a2a67301423bc20226b61" ]
+ },
+ "manjaro": {
+ "name": "Manjaro",
+ "image": "manjarolinux/base",
+ "layers": [ "sha256:216c2b07dc6cdef63748d768bbfcd394fcde275397835cb973d6aa857e9983a8" ]
+ },
+ "scientificlinux": {
+ "name": "Scientific Linux",
+ "image": "sl:latest",
+ "layers": [ "sha256:59d57c9268c8301abd28f5554dc4d14497c7cc8a281c85e06aafa8db92a1d079"]
+ },
+ "crux": {
+ "name": "Crux Linux",
+ "image": "crux:latest",
+ "layers": [ "sha256:180a5b3bafc3c941332c0ca2c40e004ae0aabfa7173a28d5ca5f8562f596442a"]
+ },
+ "void": {
+ "name": "Void Linux",
+ "image": "voidlinux/voidlinux",
+ "layers": [ "sha256:7a0058e958fe08e7b0265db555bcbd656ceced2f248ca41ac8547c8bc201738e", "sha256:67ec93f428d8f63dcc651f81271fa998d227078854eedbe258d054f0d9423915"]
+ },
+ "kali": {
+ "name": "Kali Linux",
+ "image": "kalilinux/kali-rolling",
+ "layers": [ "sha256:62a6cf2f6f69d34ddb39bf1a18c7ddfb3875687d4ecdae469d99acf63ccba839"]
+ },
+ "opensuseleap": {
+ "name": "OpenSuse Leap",
+ "image": "opensuse/leap",
+ "layers": [ "sha256:0883b61588de8d468e590174a7dde9545b48770afade002e3925feba38310294" ]
+ },
+ "parrot": {
+ "name": "Parrot Security OS",
+ "image": "parrotsec/security",
+ "layers": [ "sha256:250c4d9991f518f0e874345e1cb4c8da8d07bd6381b8dbd451c6c22dd607051d", "sha256:a5f5dddb8ddc210730ee23e3bbc35e9bb6173c3aeca3774e6f0fa43c10799dcc", "sha256:29060bcec7f56ba927952eca467626c723447777a6fb447f327e42c0e7f5ed58"]
+ },
+ "gentoo": {
+ "name": "Gentoo",
+ "image": "gentoo/stage3",
+ "layers": [ "sha256:915cbdf289072d1bdb8aaac4ce0808af9c9f7984738d19e3320985271c3e126d"]
+ }
+}
\ No newline at end of file