From 4dac4234adc6e8d40445dd4a3b1fb4e68f43b998 Mon Sep 17 00:00:00 2001 From: Akilan Date: Wed, 22 Feb 2023 02:46:11 +0000 Subject: [PATCH 1/6] added config flixble system --- abstractions/init.go | 11 + client/GroupTrackContainer.go | 4 +- client/TrackContainers.go | 8 +- client/clientIPTable/Iptable.go | 4 +- cmd/action.go | 44 +--- config/config.go | 255 ++++++------------- config/config_test.go | 4 +- config/generate/generate.go | 114 +++++++++ config/generate/generateFiles.go | 159 ++++++++++++ config/generate/helperFunctions.go | 39 +++ generate/Test/.gitkeep | 0 generate/generate.go | 386 ----------------------------- generate/generate_test.go | 112 --------- generate/modifyGenerate.go | 49 ---- generate/testcaseAST.go | 9 - p2p/iptable.go | 6 +- p2p/testingMetrics.go | 2 +- plugin/packageManager.go | 4 +- plugin/plugin.go | 4 +- plugin/plugin_test.go | 2 +- server/docker/docker.go | 4 +- server/server.go | 19 +- 22 files changed, 440 insertions(+), 799 deletions(-) create mode 100644 abstractions/init.go create mode 100644 config/generate/generate.go create mode 100644 config/generate/generateFiles.go create mode 100644 config/generate/helperFunctions.go delete mode 100644 generate/Test/.gitkeep delete mode 100644 generate/generate.go delete mode 100644 generate/generate_test.go delete mode 100644 generate/modifyGenerate.go delete mode 100644 generate/testcaseAST.go diff --git a/abstractions/init.go b/abstractions/init.go new file mode 100644 index 0000000..cad9841 --- /dev/null +++ b/abstractions/init.go @@ -0,0 +1,11 @@ +package abstractions + +import ( + "github.com/Akilan1999/p2p-rendering-computation/config/generate" +) + +func Init(name string) { + // set the config file with default paths + generate.SetDefaults(name) + +} diff --git a/client/GroupTrackContainer.go b/client/GroupTrackContainer.go index 77d0b25..3fb7eae 100644 --- a/client/GroupTrackContainer.go +++ b/client/GroupTrackContainer.go @@ -206,7 +206,7 @@ func (grp *Group) AddGroupToFile() error { // result to Groups func ReadGroup() (*Groups, error) { // Get Path from config - config, err := config.ConfigInit() + config, err := config.ConfigInit(nil) if err != nil { return nil, err } @@ -234,7 +234,7 @@ func (grp *Groups) WriteGroup() error { return err } // Get Path from config - config, err := config.ConfigInit() + config, err := config.ConfigInit(nil) if err != nil { return err } diff --git a/client/TrackContainers.go b/client/TrackContainers.go index c72cb80..f313595 100644 --- a/client/TrackContainers.go +++ b/client/TrackContainers.go @@ -29,7 +29,7 @@ func AddTrackContainer(d *docker.DockerVM, ipAddress string) error { return errors.New("d is nil") } //Get config information to derive paths for track containers json file - config, err := config.ConfigInit() + config, err := config.ConfigInit(nil) if err != nil { return err } @@ -81,7 +81,7 @@ func AddTrackContainer(d *docker.DockerVM, ipAddress string) error { // RemoveTrackedContainer This function removos tracked container from the trackcontainer JSON file func RemoveTrackedContainer(id string) error { //Get config information to derive paths for track containers json file - config, err := config.ConfigInit() + config, err := config.ConfigInit(nil) if err != nil { return err } @@ -118,7 +118,7 @@ func RemoveTrackedContainer(id string) error { // ViewTrackedContainers View Containers currently tracked func ViewTrackedContainers() (error, *TrackContainers) { - config, err := config.ConfigInit() + config, err := config.ConfigInit(nil) if err != nil { return err, nil } @@ -194,7 +194,7 @@ func (TC *TrackContainer) ModifyContainerInformation() error { // WriteContainers Write information back to the config file func (TC *TrackContainers) WriteContainers() error { // Initialize config file - config, err := config.ConfigInit() + config, err := config.ConfigInit(nil) // write modified information to the tracked json file data, err := json.MarshalIndent(TC, "", "\t") if err != nil { diff --git a/client/clientIPTable/Iptable.go b/client/clientIPTable/Iptable.go index 1cffa05..beb0d04 100644 --- a/client/clientIPTable/Iptable.go +++ b/client/clientIPTable/Iptable.go @@ -18,7 +18,7 @@ var mu sync.Mutex // UpdateIpTable Does the following to update it's IP table func UpdateIpTable(IpAddress string, serverPort string, wg *sync.WaitGroup) error { - config, err := config.ConfigInit() + config, err := config.ConfigInit(nil) if err != nil { return err } @@ -78,7 +78,7 @@ func UpdateIpTable(IpAddress string, serverPort string, wg *sync.WaitGroup) erro // on the ip tables func UpdateIpTableListClient() error { // Get config information - Config, err := config.ConfigInit() + Config, err := config.ConfigInit(nil) if err != nil { return err } diff --git a/cmd/action.go b/cmd/action.go index 8f4b66c..596ed79 100644 --- a/cmd/action.go +++ b/cmd/action.go @@ -4,8 +4,7 @@ import ( "fmt" "github.com/Akilan1999/p2p-rendering-computation/client" "github.com/Akilan1999/p2p-rendering-computation/client/clientIPTable" - "github.com/Akilan1999/p2p-rendering-computation/config" - "github.com/Akilan1999/p2p-rendering-computation/generate" + "github.com/Akilan1999/p2p-rendering-computation/config/generate" "github.com/Akilan1999/p2p-rendering-computation/p2p" "github.com/Akilan1999/p2p-rendering-computation/plugin" "github.com/Akilan1999/p2p-rendering-computation/server" @@ -14,10 +13,14 @@ import ( var CliAction = func(ctx *cli.Context) error { if Server { - err := server.Server() + _, err := server.Server() if err != nil { fmt.Print(err) } + + for { + + } //server.Rpc() } @@ -132,7 +135,7 @@ var CliAction = func(ctx *cli.Context) error { //Sets default paths to the config file if SetDefaultConfig { - err := config.SetDefaults() + err := generate.SetDefaults("P2PRC") if err != nil { fmt.Print(err) } @@ -247,39 +250,6 @@ var CliAction = func(ctx *cli.Context) error { } } - // Starts server as a reverse proxy so that - // nodes can connect to each other behind NAT - //if FRPProxy { - // err := frp.StartFRPProxyFromRandom() - // if err != nil { - // fmt.Println(err) - // } - //} - - // -- REMOVE ON REGULAR RELEASE -- - // when flag --gen is called an extension - // of the project is created to repurpose - // the project for custom purpose - if Generate != "" { - var err error - // If the module name is provided - if Modulename != "" { - err = generate.GenerateNewProject(Generate, Modulename) - } else { - err = generate.GenerateNewProject(Generate, Generate) - } - if err != nil { - fmt.Println(err) - } else { - fmt.Println("Created new folder: " + Generate) - fmt.Println("1. Enter inside " + Generate + " directory") - fmt.Println("2. git remote add " + Generate + " ") - fmt.Println("3. git push " + Generate + " ") - fmt.Println("4. go mod tidy") - fmt.Println("5. sh install.sh " + Generate) - fmt.Println("6. ./" + Generate + " -h (This is to test if the binary is working)") - } - } //-------------------------------- if PullPlugin != "" { diff --git a/config/config.go b/config/config.go index 9482154..27c7eca 100644 --- a/config/config.go +++ b/config/config.go @@ -1,75 +1,47 @@ package config import ( - "github.com/spf13/viper" - "io" - "os" + "github.com/spf13/viper" + "os" ) var ( - defaultPath string - defaults = map[string]interface{}{} - configName = "config" - configType = "json" - configFile = "config.json" - configPaths []string - defaultEnvName = "P2PRC" + //defaultPath string + defaults = map[string]interface{}{} + configName = "config" + configType = "json" + configFile = "config.json" + configPaths []string + defaultEnvName = "P2PRC" ) type Config struct { - MachineName string - IPTable string - DockerContainers string - DefaultDockerFile string - SpeedTestFile string - IPV6Address string - PluginPath string - TrackContainersPath string - ServerPort string - GroupTrackContainersPath string - FRPServerPort string - BehindNAT string - //NetworkInterface string - //NetworkInterfaceIPV6Index int -} - -// Exists reports whether the named file or directory exists. -func fileExists(name string) bool { - if _, err := os.Stat(name); err != nil { - if os.IsNotExist(err) { - return false - } - } - return true -} - -// Copy the src file to dst. Any existing file will be overwritten and will not -// copy file attributes. -// Source: https://stackoverflow.com/questions/21060945/simple-way-to-copy-a-file -func Copy(src, dst string) error { - in, err := os.Open(src) - if err != nil { - return err - } - defer in.Close() - - out, err := os.Create(dst) - if err != nil { - return err - } - defer out.Close() - - _, err = io.Copy(out, in) - if err != nil { - return err - } - return out.Close() + MachineName string + IPTable string + DockerContainers string + DefaultDockerFile string + SpeedTestFile string + IPV6Address string + PluginPath string + TrackContainersPath string + ServerPort string + GroupTrackContainersPath string + FRPServerPort string + BehindNAT string + //NetworkInterface string + //NetworkInterfaceIPV6Index int } // GetPathP2PRC Getting P2PRC Directory from environment variable -func GetPathP2PRC() (string, error) { - curDir := os.Getenv(defaultEnvName) - return curDir + "/", nil +func GetPathP2PRC(Envname string) (string, error) { + if Envname != "" { + err := SetEnvName(Envname) + if err != nil { + return "", err + } + } + curDir := os.Getenv(defaultEnvName) + return curDir + "/", nil } // SetEnvName Sets the environment name @@ -77,120 +49,55 @@ func GetPathP2PRC() (string, error) { // your environment variable // This is useful when extending the use case of P2PRC func SetEnvName(EnvName string) error { - defaultEnvName = EnvName - // Handling error to be implemented only if needed - return nil + defaultEnvName = EnvName + // Handling error to be implemented only if needed + return nil } -// GetCurrentPath Getting P2PRC Directory from environment variable -func GetCurrentPath() (string, error) { - curDir := os.Getenv("PWD") - return curDir + "/", nil -} - -// SetDefaults This function to be called only during a -// make install -func SetDefaults() error { - //Setting current directory to default path - defaultPath, err := GetPathP2PRC() - if err != nil { - return err - } - - //Creates ip_table.json in the json directory - err = Copy("p2p/ip_table.json", "p2p/iptable/ip_table.json") - if err != nil { - return err - } - - //Creates a copy of trackcontainers.json in the appropriate directory - err = Copy("client/trackcontainers.json", "client/trackcontainers/trackcontainers.json") - if err != nil { - return err - } - - //Creates a copy of trackcontainers.json in the appropriate directory - err = Copy("client/grouptrackcontainers.json", "client/trackcontainers/grouptrackcontainers.json") - if err != nil { - return err - } - - //Setting default paths for the config file - defaults["IPTable"] = defaultPath + "p2p/iptable/ip_table.json" - defaults["DefaultDockerFile"] = defaultPath + "server/docker/containers/docker-ubuntu-sshd/" - defaults["DockerContainers"] = defaultPath + "server/docker/containers/" - defaults["SpeedTestFile"] = defaultPath + "p2p/50.bin" - defaults["IPV6Address"] = "" - defaults["PluginPath"] = defaultPath + "plugin/deploy" - defaults["TrackContainersPath"] = defaultPath + "client/trackcontainers/trackcontainers.json" - defaults["GroupTrackContainersPath"] = defaultPath + "client/trackcontainers/grouptrackcontainers.json" - defaults["ServerPort"] = "8088" - defaults["FRPServerPort"] = "0" - defaults["BehindNAT"] = "True" - // Random name generator - hostname, err := os.Hostname() - if err != nil { - return err - } - - defaults["MachineName"] = hostname - //defaults["NetworkInterface"] = "wlp0s20f3" - //defaults["NetworkInterfaceIPV6Index"] = "2" - - //Paths to search for config file - configPaths = append(configPaths, defaultPath) - - if fileExists(defaultPath + "config.json") { - err := os.Remove(defaultPath + "config.json") - if err != nil { - return err - } - } - - //Calling configuration file - _, err = ConfigInit() - if err != nil { - return err - } - return nil -} - -func ConfigInit() (*Config, error) { - - //Setting current directory to default path - defaultPath, err := GetPathP2PRC() - if err != nil { - return nil, err - } - //Paths to search for config file - configPaths = append(configPaths, defaultPath) - - //Add all possible configurations paths - for _, v := range configPaths { - viper.AddConfigPath(v) - } - - //Read config file - if err := viper.ReadInConfig(); err != nil { - // If the error thrown is config file not found - //Sets default configuration to viper - for k, v := range defaults { - viper.SetDefault(k, v) - } - viper.SetConfigName(configName) - viper.SetConfigFile(configFile) - viper.SetConfigType(configType) - - if err = viper.WriteConfig(); err != nil { - return nil, err - } - } - - // Adds configuration to the struct - var config Config - if err := viper.Unmarshal(&config); err != nil { - return nil, err - } - - return &config, nil +// ConfigInit Pass environment name as an optional parameter +func ConfigInit(defaultsParameter map[string]interface{}, envNameOptional ...string) (*Config, error) { + if len(envNameOptional) > 0 { + defaultEnvName = envNameOptional[0] + } + + if defaultsParameter != nil { + defaults = defaultsParameter + } + + //Setting current directory to default path + defaultPath, err := GetPathP2PRC(defaultEnvName) + if err != nil { + return nil, err + } + //Paths to search for config file + configPaths = append(configPaths, defaultPath) + + //Add all possible configurations paths + for _, v := range configPaths { + viper.AddConfigPath(v) + } + + //Read config file + if err := viper.ReadInConfig(); err != nil { + // If the error thrown is config file not found + //Sets default configuration to viper + for k, v := range defaults { + viper.SetDefault(k, v) + } + viper.SetConfigName(configName) + viper.SetConfigFile(configFile) + viper.SetConfigType(configType) + + if err = viper.WriteConfig(); err != nil { + return nil, err + } + } + + // Adds configuration to the struct + var config Config + if err := viper.Unmarshal(&config); err != nil { + return nil, err + } + + return &config, nil } diff --git a/config/config_test.go b/config/config_test.go index 2f9857f..af5f850 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -7,7 +7,7 @@ import ( ) func TestConfigInit(t *testing.T) { - _,err := ConfigInit() + _, err := ConfigInit(nil) if err != nil { t.Error(err) } @@ -60,4 +60,4 @@ func TestSetEnvName(t *testing.T) { t.Error(err) } fmt.Println(path) -} \ No newline at end of file +} diff --git a/config/generate/generate.go b/config/generate/generate.go new file mode 100644 index 0000000..f4b7415 --- /dev/null +++ b/config/generate/generate.go @@ -0,0 +1,114 @@ +package generate + +import ( + "github.com/Akilan1999/p2p-rendering-computation/config" + "os" +) + +var ( + defaults = map[string]interface{}{} + configPaths []string + defaultEnvName = "P2PRC" +) + +// GetPathP2PRC Getting P2PRC Directory from environment variable +func GetPathP2PRC() (string, error) { + curDir := os.Getenv(defaultEnvName) + return curDir + "/", nil +} + +// SetEnvName Sets the environment name +// This is to ensure that the Path of your project is detected from +// your environment variable +// This is useful when extending the use case of P2PRC +func SetEnvName(EnvName string) error { + if EnvName != "" { + defaultEnvName = EnvName + } + // Handling error to be implemented only if needed + return nil +} + +// GetCurrentPath Getting P2PRC Directory from environment variable +func GetCurrentPath() (string, error) { + curDir := os.Getenv("PWD") + return curDir + "/", nil +} + +// SetDefaults This function to be called only during a +// make install +func SetDefaults(envName string) error { + //Setting current directory to default path + defaultPath, err := GetCurrentPath() + if err != nil { + return err + } + + // Set Env name + err = SetEnvName(envName) + if err != nil { + return err + } + + ////Creates ip_table.json in the json directory + //err = Copy("p2p/ip_table.json", "p2p/iptable/ip_table.json") + //if err != nil { + // return err + //} + // + ////Creates a copy of trackcontainers.json in the appropriate directory + //err = Copy("client/trackcontainers.json", "client/trackcontainers/trackcontainers.json") + //if err != nil { + // return err + //} + // + ////Creates a copy of trackcontainers.json in the appropriate directory + //err = Copy("client/grouptrackcontainers.json", "client/trackcontainers/grouptrackcontainers.json") + //if err != nil { + // return err + //} + + //Setting default paths for the config file + defaults["IPTable"] = defaultPath + "p2p/iptable/ip_table.json" + defaults["DefaultDockerFile"] = defaultPath + "server/docker/containers/docker-ubuntu-sshd/" + defaults["DockerContainers"] = defaultPath + "server/docker/containers/" + defaults["SpeedTestFile"] = defaultPath + "p2p/50.bin" + defaults["IPV6Address"] = "" + defaults["PluginPath"] = defaultPath + "plugin/deploy" + defaults["TrackContainersPath"] = defaultPath + "client/trackcontainers/trackcontainers.json" + defaults["GroupTrackContainersPath"] = defaultPath + "client/trackcontainers/grouptrackcontainers.json" + defaults["ServerPort"] = "8088" + defaults["FRPServerPort"] = "0" + defaults["BehindNAT"] = "True" + // Random name generator + hostname, err := os.Hostname() + if err != nil { + return err + } + + defaults["MachineName"] = hostname + //defaults["NetworkInterface"] = "wlp0s20f3" + //defaults["NetworkInterfaceIPV6Index"] = "2" + + //Paths to search for config file + configPaths = append(configPaths, defaultPath) + + if fileExists(defaultPath + "config.json") { + err := os.Remove(defaultPath + "config.json") + if err != nil { + return err + } + } + + //Calling configuration file + _, err = config.ConfigInit(defaults, envName) + if err != nil { + return err + } + + err = GenerateFiles() + if err != nil { + return err + } + return nil +} diff --git a/config/generate/generateFiles.go b/config/generate/generateFiles.go new file mode 100644 index 0000000..41cb816 --- /dev/null +++ b/config/generate/generateFiles.go @@ -0,0 +1,159 @@ +package generate + +import ( + "github.com/Akilan1999/p2p-rendering-computation/p2p" + "os" +) + +// GenerateFiles Generates all the files needed to setup P2PRC +func GenerateFiles(rootNodes ...p2p.IpAddress) (err error) { + err = GenerateIPTableFile(rootNodes) + err = GenerateDockerFiles() + err = GeneratePluginDirectory() + err = GenerateClientTrackContainers() + return +} + +// GenerateIPTableFile Generates the IPTable file with the appropirate root node +func GenerateIPTableFile(rootNodes []p2p.IpAddress) (err error) { + var rootnodes p2p.IpAddresses + var rootnode p2p.IpAddress + + err = CreateIPTableFolderStructure() + if err != nil { + return err + } + + // If root node addresses are not provided as optional parameters + if len(rootNodes) <= 0 { + rootnode.Name = "Node1" + rootnode.ServerPort = "8088" + rootnode.NAT = "False" + rootnode.Ipv4 = "64.227.168.102" + + rootnodes.IpAddress = append(rootnodes.IpAddress, rootnode) + } else { + // if root nodes are provided then override them as the optional parameter + for i := range rootNodes { + rootnodes.IpAddress = append(rootnodes.IpAddress, rootNodes[i]) + } + } + + err = rootnodes.WriteIpTable() + return +} + +// CreateIPTableFolderStructure Create folder structure for IPTable +func CreateIPTableFolderStructure() (err error) { + path, err := GetCurrentPath() + if err != nil { + return err + } + if _, err = os.Stat(path + "p2p"); os.IsNotExist(err) { + if err = os.Mkdir(path+"p2p", os.ModePerm); err != nil { + return err + } + if _, err = os.Stat(path + "p2p/iptable"); os.IsNotExist(err) { + if err = os.Mkdir(path+"p2p/iptable", os.ModePerm); err != nil { + return err + } + } + if _, err = os.Stat(path + "p2p/iptable/ip_table.json"); os.IsNotExist(err) { + _, err = os.Create(path + "p2p/iptable/ip_table.json") + if err != nil { + return err + } + } + + } + + return +} + +// GenerateDockerFiles Generate default docker files +func GenerateDockerFiles() (err error) { + path, err := GetCurrentPath() + if err != nil { + return err + } + if _, err = os.Stat(path + "server"); os.IsNotExist(err) { + if err = os.Mkdir(path+"server", os.ModePerm); err != nil { + return err + } + if _, err = os.Stat(path + "server/docker"); os.IsNotExist(err) { + if err = os.Mkdir(path+"server/docker", os.ModePerm); err != nil { + return err + } + } + if _, err = os.Stat(path + "server/docker/containers"); os.IsNotExist(err) { + if err = os.Mkdir(path+"server/docker/containers", os.ModePerm); err != nil { + return err + } + } + if _, err = os.Stat(path + "server/docker/containers"); os.IsNotExist(err) { + if err = os.Mkdir(path+"server/docker/containers", os.ModePerm); err != nil { + return err + } + } + if _, err = os.Stat(path + "server/docker/containers/docker-ubuntu-sshd"); os.IsNotExist(err) { + if err = os.Mkdir(path+"server/docker/containers/docker-ubuntu-sshd", os.ModePerm); err != nil { + return err + } + } + //if _, err = os.Stat(path + "server/docker/ip_table.json"); os.IsNotExist(err) { + // _, err = os.Create(path + "p2p/iptable/ip_table.json") + // if err != nil { + // return err + // } + //} + + } + return +} + +// GeneratePluginDirectory Generates plugin directory structure +func GeneratePluginDirectory() (err error) { + path, err := GetCurrentPath() + if err != nil { + return err + } + if _, err = os.Stat(path + "plugin"); os.IsNotExist(err) { + if err = os.Mkdir(path+"plugin", os.ModePerm); err != nil { + return err + } + if _, err = os.Stat(path + "plugin/deploy"); os.IsNotExist(err) { + if err = os.Mkdir(path+"plugin/deploy", os.ModePerm); err != nil { + return err + } + } + } + return +} + +func GenerateClientTrackContainers() (err error) { + path, err := GetCurrentPath() + if err != nil { + return err + } + if _, err = os.Stat(path + "client"); os.IsNotExist(err) { + if err = os.Mkdir(path+"client", os.ModePerm); err != nil { + return err + } + + if _, err = os.Stat(path + "client/trackcontainers.json"); os.IsNotExist(err) { + _, err = os.Create(path + "client/trackcontainers.json") + if err != nil { + return err + } + } + + if _, err = os.Stat(path + "client/grouptrackcontainers.json"); os.IsNotExist(err) { + _, err = os.Create(path + "client/grouptrackcontainers.json") + if err != nil { + return err + } + } + + } + return +} diff --git a/config/generate/helperFunctions.go b/config/generate/helperFunctions.go new file mode 100644 index 0000000..048afb8 --- /dev/null +++ b/config/generate/helperFunctions.go @@ -0,0 +1,39 @@ +package generate + +import ( + "io" + "os" +) + +// Exists reports whether the named file or directory exists. +func fileExists(name string) bool { + if _, err := os.Stat(name); err != nil { + if os.IsNotExist(err) { + return false + } + } + return true +} + +// Copy the src file to dst. Any existing file will be overwritten and will not +// copy file attributes. +// Source: https://stackoverflow.com/questions/21060945/simple-way-to-copy-a-file +func Copy(src, dst string) error { + in, err := os.Open(src) + if err != nil { + return err + } + defer in.Close() + + out, err := os.Create(dst) + if err != nil { + return err + } + defer out.Close() + + _, err = io.Copy(out, in) + if err != nil { + return err + } + return out.Close() +} diff --git a/generate/Test/.gitkeep b/generate/Test/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/generate/generate.go b/generate/generate.go deleted file mode 100644 index d68b11b..0000000 --- a/generate/generate.go +++ /dev/null @@ -1,386 +0,0 @@ -// Package generate The purpose of this package is to ensure that we can extend the use-case of P2PRC. -// We will create a project directory with the template to extend the use-case of P2PRC -package generate - -import ( - "fmt" - "github.com/Akilan1999/p2p-rendering-computation/config" - "github.com/otiai10/copy" - "go/ast" - "go/token" - modfile "golang.org/x/mod/modfile" - "io/ioutil" - "os" - "os/exec" - "strings" -) - -// NewProject Struct information required when creating a new project -type NewProject struct { - Name string - Module string - NewDir string - P2PRCPath string - CurrentModule string - Option *copy.Options - Token *token.FileSet - AST *ast.File - FileNameAST string -} - -// GenerateNewProject creates a new copy of the P2PRC -// project for custom modification -func GenerateNewProject(name string, module string) error { - // Create new variable of type NewProject - var newProject NewProject - //Setting module name to the new project - newProject.Module = module - // Get path of the current directory - curDir, err := config.GetCurrentPath() - if err != nil { - return err - } - // Folder name of the new generated project - newProject.NewDir = curDir + name + "/" - // Create a new folder based on name entered - err = CreateFolder(name, curDir) - if err != nil { - return err - } - // get path of P2PRC - P2PRCPATH, err := config.GetPathP2PRC() - if err != nil { - return err - } - // Assign P2PRC path to the newly generated project - newProject.P2PRCPath = P2PRCPATH - // Steps: - // - copy all files from P2PRC - // - remove go.mod and go.sum and create new ones - - // Files we require to skip - - var Options copy.Options - - // IF YOU ARE RELEASING AN EXTENSION OF P2PRC - // MODIFY HERE (AN EXTENSION FROM YOUR EXTENSION :P) - // Skip or have the appropriate files and directories not needed - //---------------------------------------------------------------- - // Action performed: - // - Ensuring main.go file exists - // - Ensuring generate.go file exists - // - Ensuring modifyGenerate.go file exists - // - Ensuring generate_test.go file exists - // - Ensuring server/server.go file exists - // - Ensuring server/gopsutil.go file exists - // - Ensuring server/gpu.go file exists - // - Ensuring cmd/action.go file exists - // - Ensuring cmd/flags.go file exists - // - Skipping all .go files apart from the ones listed above - // - Skipping go.mod file - // - Skipping go.sum file - // - Skipping .idea/ directory - // - Skipping Makefile file - // - Skipping / directory - //---------------------------------------------------------------- - Options.Skip = func(src string) (bool, error) { - switch { - case strings.HasSuffix(src, "main.go"): - return false, nil - case strings.HasSuffix(src, "generate.go"): - return false, nil - case strings.HasSuffix(src, "modifyGenerate.go"): - return false, nil - case strings.HasSuffix(src, "generate_test.go"): - return false, nil - case strings.HasSuffix(src, "server/server.go"): - return false, nil - case strings.HasSuffix(src, "server/gopsutil.go"): - return false, nil - case strings.HasSuffix(src, "server/gpu.go"): - return false, nil - case strings.HasSuffix(src, "cmd/action.go"): - return false, nil - case strings.HasSuffix(src, "cmd/flags.go"): - return false, nil - case strings.HasSuffix(src, "config/config.go"): - return false, nil - case strings.HasSuffix(src, "config/config_test.go"): - return false, nil - case strings.HasSuffix(src, ".go"): - return true, nil - case strings.HasSuffix(src, "go.mod"): - return true, nil - case strings.HasSuffix(src, "go.sum"): - return true, nil - case strings.HasSuffix(src, ".idea"): - return true, nil - case strings.HasSuffix(src, "Makefile"): - return true, nil - case strings.HasSuffix(src, name): - return true, nil - default: - return false, nil - } - } - - // Storing type option in the struct new project - newProject.Option = &Options - - // Copies all files from P2PRC to the new project created - err = copy.Copy(newProject.P2PRCPath, newProject.NewDir, *newProject.Option) - if err != nil { - return err - } - - // Creating a new go.mod file in the appropriate directory - err = newProject.CreateGoMod() - if err != nil { - return err - } - - // Get current project mod name - err = newProject.GetCurrentGoModule() - if err != nil { - return err - } - - // Change the appropriate imports - err = newProject.ChangeImportFiles() - if err != nil { - return err - } - - // Add changes inside the new project - err = newProject.GitAdd() - if err != nil { - return err - } - - // commit changes inside the new project - err = newProject.GitCommit() - if err != nil { - return err - } - // Creates go.sum file - //err = newProject.CreateGoModTidy() - //if err != nil { - // return err - //} - - return nil -} - -// CreateFolder Creates a new folder based on the name and path provided -func CreateFolder(name string, path string) error { - //Create a folder/directory at a full qualified path - err := os.Mkdir(path+name, 0755) - if err != nil { - return err - } - return nil -} - -// CreateGoMod Creates a new go module for the new project created -func (a *NewProject) CreateGoMod() error { - // Create new go.mod in the appropriate directory - cmd := exec.Command("go", "mod", "init", a.Module) - cmd.Dir = a.NewDir - if err := cmd.Run(); err != nil { - return err - } - return nil -} - -func (a *NewProject) CreateGoModTidy() error { - // Installs all the appropriate dependencies and creates go.sum - cmd := exec.Command("go", "mod", "tidy") - cmd.Dir = a.NewDir - if err := cmd.Run(); err != nil { - return err - } - return nil -} - -// ChangeImportFiles Changes Appropriate imports in the appropriate file -func (a *NewProject) ChangeImportFiles() error { - // IF YOU ARE RELEASING AN EXTENSION OF P2PRC - // MODIFY HERE (AN EXTENSION FROM YOUR EXTENSION :P) - //---------------------------------------------------------------- - // Action performed: - // Files we would need to modify the imports in - // - generate/generate.go -> config module - // - generate/generate_test.go -> config module - // - cmd/action.go -> config module, server module, generate module - // - cmd/flags.go -> config module, server module, generate module - // - server/server.go -> config module - // - main.go -> cmd module - //----------------------------------------------------------------- - - //----------------------------------------------------------------- - // 1.0 - generate/generate.go -> config module - a.FileNameAST = a.NewDir + "generate/generate.go" - // Get AST information of the file - err := a.GetASTGoFile() - if err != nil { - return err - } - // Change the appropriate Go file - err = a.ChangeImports(a.CurrentModule+"/config", a.Module+"/config") - if err != nil { - return err - } - // Writes the change to the appropriate file - err = a.WriteGoAst() - if err != nil { - return err - } - //----------------------------------------------------------------- - // 1.1 - generate/generate_test.go -> config module - a.FileNameAST = a.NewDir + "generate/generate_test.go" - // Get AST information of the file - err = a.GetASTGoFile() - if err != nil { - return err - } - // Change the appropriate Go file - err = a.ChangeImports(a.CurrentModule+"/config", a.Module+"/config") - if err != nil { - return err - } - // Writes the change to the appropriate file - err = a.WriteGoAst() - if err != nil { - return err - } - - //----------------------------------------------------------------- - //----------------------------------------------------------------- - // 2.0 - cmd/action.go -> config module, server module, generate module - a.FileNameAST = a.NewDir + "cmd/action.go" - // Get AST information of the file - err = a.GetASTGoFile() - if err != nil { - return err - } - // Change the appropriate Go file - err = a.ChangeImports(a.CurrentModule+"/config", a.Module+"/config") - if err != nil { - return err - } - err = a.ChangeImports(a.CurrentModule+"/server", a.Module+"/server") - if err != nil { - return err - } - err = a.ChangeImports(a.CurrentModule+"/generate", a.Module+"/generate") - if err != nil { - return err - } - // Writes the change to the appropriate file - err = a.WriteGoAst() - if err != nil { - return err - } - //----------------------------------------------------------------- - // 2.1 - cmd/flags.go -> config module, server module, generate module - a.FileNameAST = a.NewDir + "cmd/flags.go" - // Get AST information of the file - err = a.GetASTGoFile() - if err != nil { - return err - } - // Change the appropriate Go file - err = a.ChangeImports(a.CurrentModule+"/config", a.Module+"/config") - if err != nil { - return err - } - err = a.ChangeImports(a.CurrentModule+"/server", a.Module+"/server") - if err != nil { - return err - } - err = a.ChangeImports(a.CurrentModule+"/generate", a.Module+"/generate") - if err != nil { - return err - } - // Writes the change to the appropriate file - err = a.WriteGoAst() - if err != nil { - return err - } - //----------------------------------------------------------------- - //----------------------------------------------------------------- - // 3.0 - server/server.go -> config module - a.FileNameAST = a.NewDir + "server/server.go" - // Get AST information of the file - err = a.GetASTGoFile() - if err != nil { - return err - } - // Change the appropriate Go file - err = a.ChangeImports(a.CurrentModule+"/config", a.Module+"/config") - if err != nil { - return err - } - // Writes the change to the appropriate file - err = a.WriteGoAst() - if err != nil { - return err - } - //----------------------------------------------------------------- - //----------------------------------------------------------------- - // 4.0 - server/server.go -> config module - a.FileNameAST = a.NewDir + "main.go" - // Get AST information of the file - err = a.GetASTGoFile() - if err != nil { - return err - } - // Change the appropriate Go file - err = a.ChangeImports(a.CurrentModule+"/cmd", a.Module+"/cmd") - if err != nil { - return err - } - // Writes the change to the appropriate file - err = a.WriteGoAst() - if err != nil { - return err - } - //----------------------------------------------------------------- - - return nil -} - -// GetCurrentGoModule Gets the current go module name -func (a *NewProject) GetCurrentGoModule() error { - goModBytes, err := ioutil.ReadFile(a.P2PRCPath + "go.mod") - if err != nil { - return err - } - modName := modfile.ModulePath(goModBytes) - fmt.Fprintf(os.Stdout, "modName=%+v\n", modName) - - // Set current module to struct of file NewProject - a.CurrentModule = modName - - return nil -} - -func (a *NewProject) GitAdd() error { - // Installs all the appropriate dependencies and creates go.sum - cmd := exec.Command("git", "add", ".") - cmd.Dir = a.NewDir - if err := cmd.Run(); err != nil { - return err - } - return nil -} - -func (a *NewProject) GitCommit() error { - // Installs all the appropriate dependencies and creates go.sum - cmd := exec.Command("git", "commit", "-m=removed appropriate go files") - cmd.Dir = a.NewDir - if err := cmd.Run(); err != nil { - return err - } - return nil -} diff --git a/generate/generate_test.go b/generate/generate_test.go deleted file mode 100644 index 38a2e3d..0000000 --- a/generate/generate_test.go +++ /dev/null @@ -1,112 +0,0 @@ -package generate - -import ( - "fmt" - "github.com/Akilan1999/p2p-rendering-computation/config" - "testing" -) - -// Tests the create folder function creates a folder -// This test will create a folder in the temporary -// directory -func TestCreateFolder(t *testing.T) { - err := CreateFolder("test", "/tmp/") - if err != nil { - t.Error(err) - } -} - -// Testing if a new project is created successfully -func TestGenerateNewProject(t *testing.T) { - // Checking if a new project is created successfully - err := GenerateNewProject("p2prctest", "p2prctest") - if err != nil { - fmt.Println(err) - t.Error(err) - } -} - -// Testing AST function to ensure imports are -// working as intended -func TestChangingImportAST(t *testing.T) { - // Create a new variable of type NewProject - var np NewProject - // Get current directory - path, err := config.GetCurrentPath() - if err != nil { - fmt.Println(err) - t.Error(err) - } - // Create testcase scenario - err = config.Copy(path+"testcaseAST.go", path+"/Test/testcaseAST.go") - if err != nil { - fmt.Println(err) - t.Error(err) - } - // Sets new directory to the folder test - np.NewDir = path + "Test/" - // Sets file name to be opened and modified in the AST - np.FileNameAST = path + "Test/" + "testcaseAST.go" - // Call the Read AST function - err = np.GetASTGoFile() - if err != nil { - fmt.Println(err) - t.Error(err) - } - // Change an import - err = np.ChangeImports("fmt", "lolol") - if err != nil { - fmt.Println(err) - t.Error(err) - } - // Write those saved changes - err = np.WriteGoAst() - if err != nil { - fmt.Println(err) - t.Error(err) - } - -} - -// Testing the if Go Mod is created -func TestNewProject_CreateGoMod(t *testing.T) { - // Create a new variable of type NewProject - var np NewProject - path, err := config.GetCurrentPath() - if err != nil { - fmt.Println(err) - t.Error(err) - } - // Set new project name as Test - np.Name = "Test" - // Set new project module as github.com/Test - np.Module = "github.com/Test" - // Set Path of the new project - np.NewDir = path + "Test/" - // Creating a go.mod file - err = np.CreateGoMod() - if err != nil { - fmt.Println(err) - t.Error(err) - } -} - -// Testing if the current go module is returned -func TestNewProject_GetCurrentGoModule(t *testing.T) { - // Create a new variable of type NewProject - var np NewProject - path, err := config.GetPathP2PRC() - if err != nil { - fmt.Println(err) - t.Error(err) - } - // Set Current project path - np.P2PRCPath = path - // Get module name - err = np.GetCurrentGoModule() - if err != nil { - fmt.Println(err) - t.Error(err) - } - fmt.Println(np.CurrentModule) -} diff --git a/generate/modifyGenerate.go b/generate/modifyGenerate.go deleted file mode 100644 index cc66061..0000000 --- a/generate/modifyGenerate.go +++ /dev/null @@ -1,49 +0,0 @@ -package generate - -import ( - "go/parser" - "go/printer" - "go/token" - "os" -) - - -// GetASTGoFile Gets AST of the Go file provided -func (np *NewProject)GetASTGoFile() error{ - fset := token.NewFileSet() - node, err := parser.ParseFile(fset, np.FileNameAST, nil, parser.ParseComments) - if err != nil { - return err - } - //Write Token information to the struct - np.Token = fset - // Write AST information the struct - np.AST = node - return nil -} - -// ChangeImports Changes import of the AST -func (np *NewProject)ChangeImports(CurrentImport string,ChangedImport string) error { - // Iterating through the loop and changing the appropriate import - for i, spec := range np.AST.Imports { - // If the current import is found then change it - if spec.Path.Value == "\"" + CurrentImport + "\"" { - np.AST.Imports[i].Path.Value = "\"" + ChangedImport + "\"" - } - } - return nil -} - -// WriteGoAst Write changed imports back to the AST -func (np *NewProject)WriteGoAst() error { - // write new AST to file - f, err := os.Create(np.FileNameAST) - if err != nil { - return nil - } - defer f.Close() - if err := printer.Fprint(f, np.Token, np.AST); err != nil { - return err - } - return nil -} \ No newline at end of file diff --git a/generate/testcaseAST.go b/generate/testcaseAST.go deleted file mode 100644 index 0d1dfbb..0000000 --- a/generate/testcaseAST.go +++ /dev/null @@ -1,9 +0,0 @@ -package generate - -import ( - "fmt" -) - -func TestCaseAST() { - fmt.Println("lol") -} \ No newline at end of file diff --git a/p2p/iptable.go b/p2p/iptable.go index 319fc4d..1facb68 100644 --- a/p2p/iptable.go +++ b/p2p/iptable.go @@ -36,7 +36,7 @@ type IP struct { // ReadIpTable Read data from Ip tables from json file func ReadIpTable() (*IpAddresses, error) { // Get Path from config - config, err := config.ConfigInit() + config, err := config.ConfigInit(nil) if err != nil { return nil, err } @@ -101,7 +101,7 @@ func (i *IpAddresses) WriteIpTable() error { } // Get Path from config - config, err := config.ConfigInit() + config, err := config.ConfigInit(nil) if err != nil { return err } @@ -189,7 +189,7 @@ func CurrentPublicIP() (string, error) { // GetCurrentIPV6 gets the current IPV6 address based on the interface // specified in the config file func GetCurrentIPV6() (string, error) { - Config, err := config.ConfigInit() + Config, err := config.ConfigInit(nil) if err != nil { return "", err } diff --git a/p2p/testingMetrics.go b/p2p/testingMetrics.go index 002870a..95e3772 100644 --- a/p2p/testingMetrics.go +++ b/p2p/testingMetrics.go @@ -99,7 +99,7 @@ func (s *IpAddress) UploadSpeed() error { // Get upload file path from config file // Get Path from config - config, err := config.ConfigInit() + config, err := config.ConfigInit(nil) if err != nil { return err } diff --git a/plugin/packageManager.go b/plugin/packageManager.go index 493cd4b..c651d66 100644 --- a/plugin/packageManager.go +++ b/plugin/packageManager.go @@ -24,7 +24,7 @@ func DownloadPlugin(pluginurl string) error { // Replaces / with _ folder := strings.Replace(path, "/", "_", -1) // Reads plugin path from the config path - config, err := config.ConfigInit() + config, err := config.ConfigInit(nil) if err != nil { return err } @@ -44,7 +44,7 @@ func DownloadPlugin(pluginurl string) error { // DeletePlugin The following function deletes a plugin based on // the plugin name provided. func DeletePlugin(pluginname string) error { - config, err := config.ConfigInit() + config, err := config.ConfigInit(nil) if err != nil { return err } diff --git a/plugin/plugin.go b/plugin/plugin.go index 6af3df7..2dd72f2 100644 --- a/plugin/plugin.go +++ b/plugin/plugin.go @@ -67,7 +67,7 @@ type Host struct { // DetectPlugins Detects all the plugins available func DetectPlugins() (*Plugins, error) { - config, err := config.ConfigInit() + config, err := config.ConfigInit(nil) if err != nil { return nil, err } @@ -141,7 +141,7 @@ func RunPlugin(pluginName string, IPAddresses []*ExecuteIP) (*Plugin, error) { plugindetected = plugin plugindetected.Execute = IPAddresses // Get Execute plugin path from config file - config, err := config.ConfigInit() + config, err := config.ConfigInit(nil) if err != nil { return nil, err } diff --git a/plugin/plugin_test.go b/plugin/plugin_test.go index a95073d..c83f4f4 100644 --- a/plugin/plugin_test.go +++ b/plugin/plugin_test.go @@ -74,7 +74,7 @@ func TestExecuteIP_ModifyHost(t *testing.T) { var testip ExecuteIP // Get plugin path from config file - Config, err := config.ConfigInit() + Config, err := config.ConfigInit(nil) if err != nil { fmt.Println(err) t.Fail() diff --git a/server/docker/docker.go b/server/docker/docker.go index a60def8..c51cb76 100644 --- a/server/docker/docker.go +++ b/server/docker/docker.go @@ -84,7 +84,7 @@ func BuildRunContainer(NumPorts int, GPU string, ContainerName string) (*DockerV //Default parameters RespDocker.TagName = "p2p-ubuntu" // Get Path from config - config, err := config.ConfigInit() + config, err := config.ConfigInit(nil) if err != nil { return nil, err } @@ -330,7 +330,7 @@ func StopAndRemoveContainer(containername string) error { // ViewAllContainers returns all containers runnable and which can be built func ViewAllContainers() (*DockerContainers, error) { // Traverse the deploy path as per given in the config file - config, err := config.ConfigInit() + config, err := config.ConfigInit(nil) if err != nil { return nil, err } diff --git a/server/server.go b/server/server.go index b046765..103bd8c 100644 --- a/server/server.go +++ b/server/server.go @@ -15,13 +15,13 @@ import ( "time" ) -func Server() error { +func Server() (*gin.Engine, error) { r := gin.Default() //Get Server port based on the config file - config, err := config.ConfigInit() + config, err := config.ConfigInit(nil) if err != nil { - return err + return nil, err } // update IPTable with new port and ip address and update ip table @@ -172,7 +172,7 @@ func Server() error { if config.BehindNAT == "True" { table, err := p2p.ReadIpTable() if err != nil { - return err + return nil, err } var lowestLatency int64 @@ -192,14 +192,14 @@ func Server() error { if lowestLatency != 10000000 { serverPort, err := frp.GetFRPServerPort("http://" + lowestLatencyIpAddress.Ipv4 + ":" + lowestLatencyIpAddress.ServerPort) if err != nil { - return err + return nil, err } // Create 3 second delay to allow FRP server to start time.Sleep(1 * time.Second) // Starts FRP as a client with proxyPort, err := frp.StartFRPClientForServer(lowestLatencyIpAddress.Ipv4, serverPort, config.ServerPort) if err != nil { - return err + return nil, err } // updating with the current proxy address @@ -220,10 +220,7 @@ func Server() error { } // Run gin server on the specified port - err = r.Run(":" + config.ServerPort) - if err != nil { - return err - } + go r.Run(":" + config.ServerPort) - return nil + return r, nil } From 60500620db62d40056cb184303f6ac5177d71e0b Mon Sep 17 00:00:00 2001 From: Akilan Date: Wed, 22 Feb 2023 03:15:49 +0000 Subject: [PATCH 2/6] added base abstraction functions --- abstractions/init.go | 25 ++++++++++++++++++++----- config/config_test.go | 9 +++++---- config/generate/generate.go | 4 ++-- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/abstractions/init.go b/abstractions/init.go index cad9841..4a5f149 100644 --- a/abstractions/init.go +++ b/abstractions/init.go @@ -1,11 +1,26 @@ package abstractions import ( - "github.com/Akilan1999/p2p-rendering-computation/config/generate" + "github.com/Akilan1999/p2p-rendering-computation/config/generate" + "github.com/Akilan1999/p2p-rendering-computation/server" + "github.com/gin-gonic/gin" ) -func Init(name string) { - // set the config file with default paths - generate.SetDefaults(name) - +// Init Initialises p2prc +func Init(name string) (err error) { + // set the config file with default paths + err = generate.SetDefaults(name, false) + if err != nil { + return + } + return +} + +// Start p2prc in a server mode +func Start() (*gin.Engine, error) { + engine, err := server.Server() + if err != nil { + return nil, err + } + return engine, nil } diff --git a/config/config_test.go b/config/config_test.go index af5f850..811d666 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -2,6 +2,7 @@ package config import ( "fmt" + "github.com/Akilan1999/p2p-rendering-computation/config/generate" "os" "testing" ) @@ -14,14 +15,14 @@ func TestConfigInit(t *testing.T) { } func TestSetDefaults(t *testing.T) { - err := SetDefaults() + err := generate.SetDefaults("") if err != nil { t.Error(err) } } func TestGetCurrentPath(t *testing.T) { - path, err := GetCurrentPath() + path, err := generate.GetCurrentPath() if err != nil { fmt.Println(err) t.Error(err) @@ -30,7 +31,7 @@ func TestGetCurrentPath(t *testing.T) { } func TestGetPathP2PRC(t *testing.T) { - path, err := GetPathP2PRC() + path, err := GetPathP2PRC("") if err != nil { fmt.Println(err) t.Error(err) @@ -54,7 +55,7 @@ func TestSetEnvName(t *testing.T) { } // Checks if the output for the default read is "lol" - path, err := GetPathP2PRC() + path, err := GetPathP2PRC("") if err != nil { fmt.Println(err) t.Error(err) diff --git a/config/generate/generate.go b/config/generate/generate.go index f4b7415..bf64b87 100644 --- a/config/generate/generate.go +++ b/config/generate/generate.go @@ -37,7 +37,7 @@ func GetCurrentPath() (string, error) { // SetDefaults This function to be called only during a // make install -func SetDefaults(envName string) error { +func SetDefaults(envName string, forceDefault bool) error { //Setting current directory to default path defaultPath, err := GetCurrentPath() if err != nil { @@ -93,7 +93,7 @@ func SetDefaults(envName string) error { //Paths to search for config file configPaths = append(configPaths, defaultPath) - if fileExists(defaultPath + "config.json") { + if fileExists(defaultPath+"config.json") && forceDefault { err := os.Remove(defaultPath + "config.json") if err != nil { return err From 73e62ba0fa13cb6bc1c05d7c33472b41a62e86f5 Mon Sep 17 00:00:00 2001 From: Akilan Date: Wed, 22 Feb 2023 17:10:14 +0000 Subject: [PATCH 3/6] docker files --- .DS_Store | Bin 6148 -> 8196 bytes .gitignore | 3 + .../containers/Akilan1999/docker-ubuntu-sshd | 1 + client/trackcontainers/.gitkeep | 0 cmd/action.go | 2 +- config/generate/generateFiles.go | 17 +++-- p2p/iptable/.gitkeep | 0 server/.DS_Store | Bin 0 -> 6148 bytes server/docker/.DS_Store | Bin 0 -> 6148 bytes server/docker/containers/README | 7 -- .../docker/containers/cpuhorovod/Dockerfile | 43 ----------- .../containers/cpuhorovod/description.txt | 1 - .../containers/cpuhorovod/scripts/start | 11 --- .../docker-ubuntu-sshd-x11/Dockerfile | 61 --------------- .../docker-ubuntu-sshd-x11/README.md | 72 ------------------ .../docker-ubuntu-sshd-x11/description.txt | 1 - .../docker-ubuntu-sshd-x11/ports.json | 16 ---- .../docker-ubuntu-sshd-x11/scripts/start | 14 ---- .../containers/docker-ubuntu-sshd/Dockerfile | 61 --------------- .../containers/docker-ubuntu-sshd/README.md | 72 ------------------ .../docker-ubuntu-sshd/description.txt | 1 - .../containers/docker-ubuntu-sshd/ports.json | 22 ------ .../docker-ubuntu-sshd/scripts/start | 11 --- .../docker/containers/gpuhorovod/Dockerfile | 41 ---------- .../containers/gpuhorovod/description.txt | 1 - .../containers/gpuhorovod/scripts/start | 11 --- server/docker/containers/ubuntuvnc/Dockerfile | 61 --------------- server/docker/containers/ubuntuvnc/README.md | 72 ------------------ .../containers/ubuntuvnc/description.txt | 1 - .../docker/containers/ubuntuvnc/scripts/start | 11 --- 30 files changed, 16 insertions(+), 598 deletions(-) create mode 160000 Akilan1999/docker-ubuntu-sshdserver/docker/containers/Akilan1999/docker-ubuntu-sshd delete mode 100644 client/trackcontainers/.gitkeep delete mode 100644 p2p/iptable/.gitkeep create mode 100644 server/.DS_Store create mode 100644 server/docker/.DS_Store delete mode 100644 server/docker/containers/README delete mode 100644 server/docker/containers/cpuhorovod/Dockerfile delete mode 100644 server/docker/containers/cpuhorovod/description.txt delete mode 100644 server/docker/containers/cpuhorovod/scripts/start delete mode 100644 server/docker/containers/docker-ubuntu-sshd-x11/Dockerfile delete mode 100644 server/docker/containers/docker-ubuntu-sshd-x11/README.md delete mode 100644 server/docker/containers/docker-ubuntu-sshd-x11/description.txt delete mode 100644 server/docker/containers/docker-ubuntu-sshd-x11/ports.json delete mode 100644 server/docker/containers/docker-ubuntu-sshd-x11/scripts/start delete mode 100644 server/docker/containers/docker-ubuntu-sshd/Dockerfile delete mode 100644 server/docker/containers/docker-ubuntu-sshd/README.md delete mode 100644 server/docker/containers/docker-ubuntu-sshd/description.txt delete mode 100644 server/docker/containers/docker-ubuntu-sshd/ports.json delete mode 100644 server/docker/containers/docker-ubuntu-sshd/scripts/start delete mode 100644 server/docker/containers/gpuhorovod/Dockerfile delete mode 100644 server/docker/containers/gpuhorovod/description.txt delete mode 100644 server/docker/containers/gpuhorovod/scripts/start delete mode 100644 server/docker/containers/ubuntuvnc/Dockerfile delete mode 100644 server/docker/containers/ubuntuvnc/README.md delete mode 100644 server/docker/containers/ubuntuvnc/description.txt delete mode 100644 server/docker/containers/ubuntuvnc/scripts/start diff --git a/.DS_Store b/.DS_Store index 987eb7eacc19e9e205575d2c0c29c58a0428c6b2..5a9b600b6ef65102eabbeb796ee79b7ef0cf98d0 100644 GIT binary patch literal 8196 zcmeI1PjAyO7{*_(U7J#db^vJykRoxN#@Ns##HH(>!z38eTHpYvByG2arAd{vtEOqF zXZQ|$1+IJ&J_dJA@Vs_5#qM^S(4^T?{JQb;*v`*RGG|02>XZIcq7@=?aBy6%BD*AU zJs)#vAv^OBQNT~MPXQg!8lBK^PHj(E0+xU!UICX3)CnCK>K}8xG-!u9=)HsZns)JZ zp@(tq>pt>w~6|AWi`fBn@zjRG8i@c+R z`QdeP%(>AzlekjrPt#HMg!$=@!XO>5um2JYh2mnV?3A6V^RayxPupW}JW17)-m%_Zx9E_JU}TNJG#cK=R>T5cT6}J)T7URC?R0!l^iw?()j%>BiRj zs=N7Y>ul9MeZGP6v(2ruvx@WJ@sk&O-J@_A#b2?`kwo@q2Q8`J7dhWI+V%I-Ug%?t zY|tu>+esA05kD-rt|Axp2`>gf#tmuSl5$bx(ZOVsC2)NN3aY74?$ zumo-#0a0wWn{^E9{3U0OkoVdyj!!r^v2LcKv>=n)aYVTtN4)rlA<8bK?5SmOrXtQD S{r3+6USi+>lDy4sGl73&oVt+! delta 177 zcmZp1XfcprU|?W$DortDU=RQ@Ie-{MGqg`E6q~50D9Qw6GlIqP8HyOPQ;L&wlJX}O zs!ukMVKHN8NCXO&FqAVON#^GO)ia<;l?4~&<>cq3gG}34=)}I5or6P=8OQ?y0d64S k3dHRj3%@f@=9e*KWSDHjBh3S}8{{646B#zg^UPre0KR%5jsO4v diff --git a/.gitignore b/.gitignore index 6397c95..801c83c 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,6 @@ generate/Test #ignore windows exe files *.exe dist/ + +# ignore docker image files +server/docker/containers/ diff --git a/Akilan1999/docker-ubuntu-sshdserver/docker/containers/Akilan1999/docker-ubuntu-sshd b/Akilan1999/docker-ubuntu-sshdserver/docker/containers/Akilan1999/docker-ubuntu-sshd new file mode 160000 index 0000000..fbee2ad --- /dev/null +++ b/Akilan1999/docker-ubuntu-sshdserver/docker/containers/Akilan1999/docker-ubuntu-sshd @@ -0,0 +1 @@ +Subproject commit fbee2ad6a9626b73dc34299cfa37e7db63230505 diff --git a/client/trackcontainers/.gitkeep b/client/trackcontainers/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/cmd/action.go b/cmd/action.go index 596ed79..c9fad39 100644 --- a/cmd/action.go +++ b/cmd/action.go @@ -135,7 +135,7 @@ var CliAction = func(ctx *cli.Context) error { //Sets default paths to the config file if SetDefaultConfig { - err := generate.SetDefaults("P2PRC") + err := generate.SetDefaults("P2PRC", false) if err != nil { fmt.Print(err) } diff --git a/config/generate/generateFiles.go b/config/generate/generateFiles.go index 41cb816..c9323b7 100644 --- a/config/generate/generateFiles.go +++ b/config/generate/generateFiles.go @@ -2,6 +2,7 @@ package generate import ( "github.com/Akilan1999/p2p-rendering-computation/p2p" + "github.com/go-git/go-git/v5" "os" ) @@ -100,14 +101,18 @@ func GenerateDockerFiles() (err error) { return err } } - //if _, err = os.Stat(path + "server/docker/ip_table.json"); os.IsNotExist(err) { - // _, err = os.Create(path + "p2p/iptable/ip_table.json") - // if err != nil { - // return err - // } - //} } + + // Clone base docker image + _, err = git.PlainClone(path+"server/docker/containers/docker-ubuntu-sshd", false, &git.CloneOptions{ + URL: "https://github.com/Akilan1999/docker-ubuntu-sshd", + Progress: os.Stdout, + }) + if err != nil { + return err + } + return } diff --git a/p2p/iptable/.gitkeep b/p2p/iptable/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/server/.DS_Store b/server/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..2575f6f5d5e6c2341820a29cd0b5bc807d4b5ae4 GIT binary patch literal 6148 zcmeHK&u`N(6n^eXmr{Xx0BIMbNL;5;wy6@@C6saCN)Q|Xm81zJT8OLsSPxaDoVWjh ze}OB13I7Wx_@3=a%^I$#LVnWo=h*MFpT8z{O+;c+MNf%_MC8C3yLVBv827VpS;w?6 zPpC0s%3q~&7N#=Xina|_0jt2SDZt-uk0O#ZqYG+&zq~0thade`rc!UjhRb4MzV#pB zB29{NH2Ntzd)+&|eP`bpI3N8la_N^rSrwBYf6q^Eq)fw`dJw)%;^lPs;DyY}Aj#rf z5t1lI$cJ}H7RlvAR#{XiuCF_szSEx$4_2$=@#xS!IUTPL-PN;W)K5>w>vi9G`1r}$ z>*+=MHIr8=YZBO>l-)CU1J|fD))W=9G(?U}Xmniqd6vp-j&|-F&>W&IsGy2UN+_ix zZrRxWSibM@rhId7s-Vf_%Y@wTUn28v3it)HEWIibt|@yQSp=0r7BzU z@9=6jbGnaw7FesK058pyKC6|-ZL_IY=iA1sgQ2YLk^<(Na0a`Sl+DE|U=`R21$cjO z;f$WaTBF)JP^c>au#0A8sPnnU9M_;{u-1qkn9x+9rV4Y#5Sos5*Ti`SYmJ&t!dyOt znOT?{icqs-d{>2&@HE=eDqt08DzK*?hkX9O{QLdCNwQB?0jt1&rGV(3`{xrZ$(*fQ xi{rD_g@1yxaa^rYQBauUSXKBaK7cDjpUV}XXRy|Y7MT4bpk%OxRp6g0@CWv6uwDQF literal 0 HcmV?d00001 diff --git a/server/docker/.DS_Store b/server/docker/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..8f300a789687d0e4883b3bf2fce3412e792c70ad GIT binary patch literal 6148 zcmeHKL2uJA6n^f?mTm%72&7$*B5@s~Y*Qt~B`fWL1D6HC0Z?h0utm$_s!7*FRVioq z5BvqL{1W~PC-|Q2p`^`@LxB7$`*ZB~+3^?qxh5jfn}tt^+C=0aF*di6)fl&PTC;|! zVV+QZj3}m*BAQaR=4~si0#<>)O#$A!+cYMLeVbEh|Gr4%I7noGb`B25Nc%sPp>z!= zm}e8i`4&u)ILkYo@1n8MytTRIY&kp5d;d(%{d|REDbZo^>u^Oa$3Xo?qYG!?d-XSN8RO~yLftl^3h>; zxokQ2A3lC|GCWT%Qu#@}Jqg4sWw#Ap!Dkd|^$4?Z65w5#SnF`b?$asBs-)rpyvmZ^sW68491+53PBmQmy25pSb0-MCk}g)p;%Sw~x{LRUDZ%ei z-N(n68J(^4@nfYAhhAdA@ccfizM`ssgOwmom<@Kesyg;>f(+Ze9 z;OyM=K(>FYfK}k1Q-I@xi^S*|EHtXnflOTifK5~@Lz(|BFvm6M87wrS1tv5VsHwtS zF@&b0-Zg%n!9t^^lQ5SLVMZ3_h9cDH=-*ZDBs`5aw+dJVstRoA$2On;gX{1ARg!(O z3RngHD+NTe@ArF{k~v$~CdX&3i}V4Bjr|IZih|4>$Ev_b@h*}ww7FaWdIk%PsDar( O0!jv(Sq1*60>1$1khi4( literal 0 HcmV?d00001 diff --git a/server/docker/containers/README b/server/docker/containers/README deleted file mode 100644 index a5ada78..0000000 --- a/server/docker/containers/README +++ /dev/null @@ -1,7 +0,0 @@ -Containers -=========== - -Structure - |_ Containers - |_ (To ensure the name is the same as the tag name) - |_ DockerFile \ No newline at end of file diff --git a/server/docker/containers/cpuhorovod/Dockerfile b/server/docker/containers/cpuhorovod/Dockerfile deleted file mode 100644 index 90e8f43..0000000 --- a/server/docker/containers/cpuhorovod/Dockerfile +++ /dev/null @@ -1,43 +0,0 @@ -from horovod/horovod-cpu -# Switch to root user to install additional software -USER 0 - - -# Make sure we don't get notifications we can't answer during building. -env DEBIAN_FRONTEND noninteractive - -run apt-get -q -y update; apt-get -q -y upgrade -run apt install net-tools - -# Prepare scripts and configs -add ./scripts/start /start - - -# Set root password -run echo 'root:password' >> /root/passwdfile - - -# Create user and it's password -run useradd -m -G sudo master && \ - echo 'master:password' >> /root/passwdfile - - -# Apply root password -run chpasswd -c SHA512 < /root/passwdfile && \ - rm /root/passwdfile - - -# Port 22 is used for ssh -expose 22 - - -# Assign /data as static volume. -volume ["/data"] - - -# Fix all permissions -run chmod +x /start - - -# Starting sshd -cmd ["/start"] \ No newline at end of file diff --git a/server/docker/containers/cpuhorovod/description.txt b/server/docker/containers/cpuhorovod/description.txt deleted file mode 100644 index 7a100b7..0000000 --- a/server/docker/containers/cpuhorovod/description.txt +++ /dev/null @@ -1 +0,0 @@ -Running official horovod dockerfile cpu version diff --git a/server/docker/containers/cpuhorovod/scripts/start b/server/docker/containers/cpuhorovod/scripts/start deleted file mode 100644 index 9dde9d0..0000000 --- a/server/docker/containers/cpuhorovod/scripts/start +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -# ----------------------------------------------------------------------------- -# docker-ubuntu-sshd /start script -# -# Authors: Art567 -# Updated: Sep 20th, 2015 -# ----------------------------------------------------------------------------- - - -# Run OpenSSH server in daemon mode -/usr/sbin/sshd -D \ No newline at end of file diff --git a/server/docker/containers/docker-ubuntu-sshd-x11/Dockerfile b/server/docker/containers/docker-ubuntu-sshd-x11/Dockerfile deleted file mode 100644 index a3628ab..0000000 --- a/server/docker/containers/docker-ubuntu-sshd-x11/Dockerfile +++ /dev/null @@ -1,61 +0,0 @@ -# ----------------------------------------------------------------------------- -# This is base image of Ubuntu LTS with SSHD service. -# -# Authors: Art567 -# Updated: Sep 20th, 2015 -# Require: Docker (http://www.docker.io/) -# ----------------------------------------------------------------------------- - - -# Base system is the latest LTS version of Ubuntu. -# from consol/ubuntu-xfce-vnc - -# due to dependency issues vnc is still work in progress -from ubuntu:20.04 - -# Switch to root user to install additional software -USER 0 - - -# Make sure we don't get notifications we can't answer during building. -env DEBIAN_FRONTEND noninteractive - - -# Prepare scripts and configs -add ./scripts/start /start - - -# Download and install everything from the repos. -run apt-get -q -y update; apt-get -q -y upgrade && \ - apt-get -q -y install sudo openssh-server && \ - mkdir /var/run/sshd - - -# Set root password -run echo 'root:password' >> /root/passwdfile - - -# Create user and it's password -run useradd -m -G sudo master && \ - echo 'master:password' >> /root/passwdfile - - -# Apply root password -run chpasswd -c SHA512 < /root/passwdfile && \ - rm /root/passwdfile - - -# Port 22 is used for ssh -expose 22 - - -# Assign /data as static volume. -volume ["/data"] - - -# Fix all permissions -run chmod +x /start - - -# Starting sshd -cmd ["/start"] diff --git a/server/docker/containers/docker-ubuntu-sshd-x11/README.md b/server/docker/containers/docker-ubuntu-sshd-x11/README.md deleted file mode 100644 index ee62e54..0000000 --- a/server/docker/containers/docker-ubuntu-sshd-x11/README.md +++ /dev/null @@ -1,72 +0,0 @@ -Ubuntu LTS with SSH (Docker) -========= - -A Docker file to build a [docker.io] base container with Ubuntu LTS and a sshd service -[docker.io]: http://docker.io -Nice and easy way to get any server up and running using docker - - -Instructions ------------ - - Install Docker first. - Read [installation instructions] (http://docs.docker.io/en/latest/installation/). - - - - Clone this repository: - - `$ git clone https://github.com/art567/docker-ubuntu-sshd.git` - - - - Enter local directory: - - `$ cd docker-ubuntu-sshd` - - - Change passwords in Dockerfile: - - `$ vi Dockerfile` - - - Build the container: - - `$ sudo docker build -t art567/ubuntu .` - - - - Run the container: - - `$ sudo docker run -d=true --name=ubuntu --restart=always -p=2222:22 -v=/opt/data:/data art567/ubuntu /start` - - - - Your container will start and bind ssh to 2222 port. - - - - Find your local IP Address: - - `$ ifconfig` - - - - Connect to the SSH server: - - `$ ssh root@ -p 2222` - - - - If you don't want to deal with root: - - `$ ssh master@ -p 2222` - - -**VERY IMPORTANT!!!** ------------ - - **Don't forget to change passwords in Dockerfile before building image!** - - -Versions ------------ -Some branches represents Ubuntu versions. - -Branch `master` is always represented by latest Ubuntu LTS - - For example: - - 12.04 - Ubuntu 12.04 LTS - - 14.04 - Ubuntu 14.04 LTS - - 16.04 - Ubuntu 16.04 LTS - diff --git a/server/docker/containers/docker-ubuntu-sshd-x11/description.txt b/server/docker/containers/docker-ubuntu-sshd-x11/description.txt deleted file mode 100644 index dc5b3fa..0000000 --- a/server/docker/containers/docker-ubuntu-sshd-x11/description.txt +++ /dev/null @@ -1 +0,0 @@ -Simple Ubuntu 20.04 image \ No newline at end of file diff --git a/server/docker/containers/docker-ubuntu-sshd-x11/ports.json b/server/docker/containers/docker-ubuntu-sshd-x11/ports.json deleted file mode 100644 index 520565b..0000000 --- a/server/docker/containers/docker-ubuntu-sshd-x11/ports.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "Port": [ - { - "PortName": "SSH", - "InternalPort": 22, - "Type": "tcp", - "Description": "SSH Port" - }, - { - "PortName": "VNC", - "InternalPort": 5900, - "Type": "tcp", - "Description": "VNC port" - } - ] -} \ No newline at end of file diff --git a/server/docker/containers/docker-ubuntu-sshd-x11/scripts/start b/server/docker/containers/docker-ubuntu-sshd-x11/scripts/start deleted file mode 100644 index 3c9caa9..0000000 --- a/server/docker/containers/docker-ubuntu-sshd-x11/scripts/start +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -# ----------------------------------------------------------------------------- -# docker-ubuntu-sshd /start script -# -# Authors: Art567 -# Updated: Sep 20th, 2015 -# ----------------------------------------------------------------------------- - - -# Run OpenSSH server in daemon mode -/usr/sbin/sshd -D - -# Running x11 server with password - diff --git a/server/docker/containers/docker-ubuntu-sshd/Dockerfile b/server/docker/containers/docker-ubuntu-sshd/Dockerfile deleted file mode 100644 index a3628ab..0000000 --- a/server/docker/containers/docker-ubuntu-sshd/Dockerfile +++ /dev/null @@ -1,61 +0,0 @@ -# ----------------------------------------------------------------------------- -# This is base image of Ubuntu LTS with SSHD service. -# -# Authors: Art567 -# Updated: Sep 20th, 2015 -# Require: Docker (http://www.docker.io/) -# ----------------------------------------------------------------------------- - - -# Base system is the latest LTS version of Ubuntu. -# from consol/ubuntu-xfce-vnc - -# due to dependency issues vnc is still work in progress -from ubuntu:20.04 - -# Switch to root user to install additional software -USER 0 - - -# Make sure we don't get notifications we can't answer during building. -env DEBIAN_FRONTEND noninteractive - - -# Prepare scripts and configs -add ./scripts/start /start - - -# Download and install everything from the repos. -run apt-get -q -y update; apt-get -q -y upgrade && \ - apt-get -q -y install sudo openssh-server && \ - mkdir /var/run/sshd - - -# Set root password -run echo 'root:password' >> /root/passwdfile - - -# Create user and it's password -run useradd -m -G sudo master && \ - echo 'master:password' >> /root/passwdfile - - -# Apply root password -run chpasswd -c SHA512 < /root/passwdfile && \ - rm /root/passwdfile - - -# Port 22 is used for ssh -expose 22 - - -# Assign /data as static volume. -volume ["/data"] - - -# Fix all permissions -run chmod +x /start - - -# Starting sshd -cmd ["/start"] diff --git a/server/docker/containers/docker-ubuntu-sshd/README.md b/server/docker/containers/docker-ubuntu-sshd/README.md deleted file mode 100644 index ee62e54..0000000 --- a/server/docker/containers/docker-ubuntu-sshd/README.md +++ /dev/null @@ -1,72 +0,0 @@ -Ubuntu LTS with SSH (Docker) -========= - -A Docker file to build a [docker.io] base container with Ubuntu LTS and a sshd service -[docker.io]: http://docker.io -Nice and easy way to get any server up and running using docker - - -Instructions ------------ - - Install Docker first. - Read [installation instructions] (http://docs.docker.io/en/latest/installation/). - - - - Clone this repository: - - `$ git clone https://github.com/art567/docker-ubuntu-sshd.git` - - - - Enter local directory: - - `$ cd docker-ubuntu-sshd` - - - Change passwords in Dockerfile: - - `$ vi Dockerfile` - - - Build the container: - - `$ sudo docker build -t art567/ubuntu .` - - - - Run the container: - - `$ sudo docker run -d=true --name=ubuntu --restart=always -p=2222:22 -v=/opt/data:/data art567/ubuntu /start` - - - - Your container will start and bind ssh to 2222 port. - - - - Find your local IP Address: - - `$ ifconfig` - - - - Connect to the SSH server: - - `$ ssh root@ -p 2222` - - - - If you don't want to deal with root: - - `$ ssh master@ -p 2222` - - -**VERY IMPORTANT!!!** ------------ - - **Don't forget to change passwords in Dockerfile before building image!** - - -Versions ------------ -Some branches represents Ubuntu versions. - -Branch `master` is always represented by latest Ubuntu LTS - - For example: - - 12.04 - Ubuntu 12.04 LTS - - 14.04 - Ubuntu 14.04 LTS - - 16.04 - Ubuntu 16.04 LTS - diff --git a/server/docker/containers/docker-ubuntu-sshd/description.txt b/server/docker/containers/docker-ubuntu-sshd/description.txt deleted file mode 100644 index dc5b3fa..0000000 --- a/server/docker/containers/docker-ubuntu-sshd/description.txt +++ /dev/null @@ -1 +0,0 @@ -Simple Ubuntu 20.04 image \ No newline at end of file diff --git a/server/docker/containers/docker-ubuntu-sshd/ports.json b/server/docker/containers/docker-ubuntu-sshd/ports.json deleted file mode 100644 index e24ff6a..0000000 --- a/server/docker/containers/docker-ubuntu-sshd/ports.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "Port": [ - { - "PortName": "SSH", - "InternalPort": 22, - "Type": "tcp", - "Description": "SSH Port" - }, - { - "PortName": "NoVNC", - "InternalPort": 5901, - "Type": "tcp", - "Description": "NoVNC port" - }, - { - "PortName": "NoVNC", - "InternalPort": 6081, - "Type": "tcp", - "Description": "NoVNC port" - } - ] -} \ No newline at end of file diff --git a/server/docker/containers/docker-ubuntu-sshd/scripts/start b/server/docker/containers/docker-ubuntu-sshd/scripts/start deleted file mode 100644 index 5286196..0000000 --- a/server/docker/containers/docker-ubuntu-sshd/scripts/start +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -# ----------------------------------------------------------------------------- -# docker-ubuntu-sshd /start script -# -# Authors: Art567 -# Updated: Sep 20th, 2015 -# ----------------------------------------------------------------------------- - - -# Run OpenSSH server in daemon mode -/usr/sbin/sshd -D diff --git a/server/docker/containers/gpuhorovod/Dockerfile b/server/docker/containers/gpuhorovod/Dockerfile deleted file mode 100644 index ed75ef6..0000000 --- a/server/docker/containers/gpuhorovod/Dockerfile +++ /dev/null @@ -1,41 +0,0 @@ -from horovod/horovod -# Switch to root user to install additional software -USER 0 - - -# Make sure we don't get notifications we can't answer during building. -env DEBIAN_FRONTEND noninteractive - - -# Prepare scripts and configs -add ./scripts/start /start - - -# Set root password -run echo 'root:password' >> /root/passwdfile - - -# Create user and it's password -run useradd -m -G sudo master && \ - echo 'master:password' >> /root/passwdfile - - -# Apply root password -run chpasswd -c SHA512 < /root/passwdfile && \ - rm /root/passwdfile - - -# Port 22 is used for ssh -expose 22 - - -# Assign /data as static volume. -volume ["/data"] - - -# Fix all permissions -run chmod +x /start - - -# Starting sshd -cmd ["/start"] \ No newline at end of file diff --git a/server/docker/containers/gpuhorovod/description.txt b/server/docker/containers/gpuhorovod/description.txt deleted file mode 100644 index 7a100b7..0000000 --- a/server/docker/containers/gpuhorovod/description.txt +++ /dev/null @@ -1 +0,0 @@ -Running official horovod dockerfile cpu version diff --git a/server/docker/containers/gpuhorovod/scripts/start b/server/docker/containers/gpuhorovod/scripts/start deleted file mode 100644 index 9dde9d0..0000000 --- a/server/docker/containers/gpuhorovod/scripts/start +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -# ----------------------------------------------------------------------------- -# docker-ubuntu-sshd /start script -# -# Authors: Art567 -# Updated: Sep 20th, 2015 -# ----------------------------------------------------------------------------- - - -# Run OpenSSH server in daemon mode -/usr/sbin/sshd -D \ No newline at end of file diff --git a/server/docker/containers/ubuntuvnc/Dockerfile b/server/docker/containers/ubuntuvnc/Dockerfile deleted file mode 100644 index d253d87..0000000 --- a/server/docker/containers/ubuntuvnc/Dockerfile +++ /dev/null @@ -1,61 +0,0 @@ -# ----------------------------------------------------------------------------- -# This is base image of Ubuntu LTS with SSHD service. -# -# Authors: Art567 -# Updated: Sep 20th, 2015 -# Require: Docker (http://www.docker.io/) -# ----------------------------------------------------------------------------- - - -# Base system is the latest LTS version of Ubuntu. -# from consol/ubuntu-xfce-vnc - -# due to dependency issues vnc is still work in progress -from dorowu/ubuntu-desktop-lxde-vnc - -# Switch to root user to install additional software -USER 0 - - -# Make sure we don't get notifications we can't answer during building. -env DEBIAN_FRONTEND noninteractive - - -# Prepare scripts and configs -add ./scripts/start /start - - -# Download and install everything from the repos. -run apt-get -q -y update; apt-get -q -y upgrade && \ - apt-get -q -y install sudo openssh-server && \ - mkdir /var/run/sshd - - -# Set root password -run echo 'root:password' >> /root/passwdfile - - -# Create user and it's password -run useradd -m -G sudo master && \ - echo 'master:password' >> /root/passwdfile - - -# Apply root password -run chpasswd -c SHA512 < /root/passwdfile && \ - rm /root/passwdfile - - -# Port 22 is used for ssh -expose 22 - - -# Assign /data as static volume. -volume ["/data"] - - -# Fix all permissions -run chmod +x /start - - -# Starting sshd -cmd ["/start"] diff --git a/server/docker/containers/ubuntuvnc/README.md b/server/docker/containers/ubuntuvnc/README.md deleted file mode 100644 index ee62e54..0000000 --- a/server/docker/containers/ubuntuvnc/README.md +++ /dev/null @@ -1,72 +0,0 @@ -Ubuntu LTS with SSH (Docker) -========= - -A Docker file to build a [docker.io] base container with Ubuntu LTS and a sshd service -[docker.io]: http://docker.io -Nice and easy way to get any server up and running using docker - - -Instructions ------------ - - Install Docker first. - Read [installation instructions] (http://docs.docker.io/en/latest/installation/). - - - - Clone this repository: - - `$ git clone https://github.com/art567/docker-ubuntu-sshd.git` - - - - Enter local directory: - - `$ cd docker-ubuntu-sshd` - - - Change passwords in Dockerfile: - - `$ vi Dockerfile` - - - Build the container: - - `$ sudo docker build -t art567/ubuntu .` - - - - Run the container: - - `$ sudo docker run -d=true --name=ubuntu --restart=always -p=2222:22 -v=/opt/data:/data art567/ubuntu /start` - - - - Your container will start and bind ssh to 2222 port. - - - - Find your local IP Address: - - `$ ifconfig` - - - - Connect to the SSH server: - - `$ ssh root@ -p 2222` - - - - If you don't want to deal with root: - - `$ ssh master@ -p 2222` - - -**VERY IMPORTANT!!!** ------------ - - **Don't forget to change passwords in Dockerfile before building image!** - - -Versions ------------ -Some branches represents Ubuntu versions. - -Branch `master` is always represented by latest Ubuntu LTS - - For example: - - 12.04 - Ubuntu 12.04 LTS - - 14.04 - Ubuntu 14.04 LTS - - 16.04 - Ubuntu 16.04 LTS - diff --git a/server/docker/containers/ubuntuvnc/description.txt b/server/docker/containers/ubuntuvnc/description.txt deleted file mode 100644 index dc5b3fa..0000000 --- a/server/docker/containers/ubuntuvnc/description.txt +++ /dev/null @@ -1 +0,0 @@ -Simple Ubuntu 20.04 image \ No newline at end of file diff --git a/server/docker/containers/ubuntuvnc/scripts/start b/server/docker/containers/ubuntuvnc/scripts/start deleted file mode 100644 index 5286196..0000000 --- a/server/docker/containers/ubuntuvnc/scripts/start +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -# ----------------------------------------------------------------------------- -# docker-ubuntu-sshd /start script -# -# Authors: Art567 -# Updated: Sep 20th, 2015 -# ----------------------------------------------------------------------------- - - -# Run OpenSSH server in daemon mode -/usr/sbin/sshd -D From be9de346e58b785376077c903e9b532971a4b138 Mon Sep 17 00:00:00 2001 From: Akilan Date: Wed, 22 Feb 2023 17:13:51 +0000 Subject: [PATCH 4/6] removed duplicate docker folder --- .../docker/containers/Akilan1999/docker-ubuntu-sshd | 1 - 1 file changed, 1 deletion(-) delete mode 160000 Akilan1999/docker-ubuntu-sshdserver/docker/containers/Akilan1999/docker-ubuntu-sshd diff --git a/Akilan1999/docker-ubuntu-sshdserver/docker/containers/Akilan1999/docker-ubuntu-sshd b/Akilan1999/docker-ubuntu-sshdserver/docker/containers/Akilan1999/docker-ubuntu-sshd deleted file mode 160000 index fbee2ad..0000000 --- a/Akilan1999/docker-ubuntu-sshdserver/docker/containers/Akilan1999/docker-ubuntu-sshd +++ /dev/null @@ -1 +0,0 @@ -Subproject commit fbee2ad6a9626b73dc34299cfa37e7db63230505 From c646a1389e64df9ad6fbbf7b1b987b18adfac748 Mon Sep 17 00:00:00 2001 From: Akilan Date: Wed, 22 Feb 2023 23:08:11 +0000 Subject: [PATCH 5/6] added other abstractions documentation to P2PRC --- Docs/Abstractions.md | 6 ++++++ Docs/README.md | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 Docs/Abstractions.md diff --git a/Docs/Abstractions.md b/Docs/Abstractions.md new file mode 100644 index 0000000..c1790a7 --- /dev/null +++ b/Docs/Abstractions.md @@ -0,0 +1,6 @@ +# Abstractions +The Abstractions package consists of blackboxed functions for P2PRC. + +## Functions +- ```Init()```: Initialises P2PRC with all the needed configurations. +- ```Start()```: Starts p2prc as a server and makes it possible to extend by adding other routes and functionality to P2PRC. \ No newline at end of file diff --git a/Docs/README.md b/Docs/README.md index e7b0f9b..0c9590c 100644 --- a/Docs/README.md +++ b/Docs/README.md @@ -2,6 +2,7 @@ # Table of contents 1. [Introduction](Introduction.md) 2. [Installation](Installation.md) +3. [Abstractions](Abstractions.md) 3. [Design Architecture](DesignArchtectureIntro.md) 1. [Client Module](ClientArchitecture.md) 2. [P2P Module](P2PArchitecture.md) @@ -13,6 +14,5 @@ 4. [Config Module](ConfigImplementation.md) 5. [Cli Module](CliImplementation.md) 6. [Plugin Module](PluginImplementation.md) - 7. [Generate Module](GenerateImplementation.md) 5. [Problems](https://github.com/Akilan1999/p2p-rendering-computation/issues) From 1428d324b1b3de0de5e5f57e032b1031e71717dd Mon Sep 17 00:00:00 2001 From: Akilan Date: Wed, 22 Feb 2023 23:10:09 +0000 Subject: [PATCH 6/6] modified README file --- README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/README.md b/README.md index 630f9ad..71ee237 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,28 @@ This project aims to create a peer to peer (p2p) network, where a user can use t
+## Extend your application with P2PRC +```go +package main + +import "github.com/Akilan1999/p2p-rendering-computation/abstractions" + +func main() { + // Initialize with base p2prc config files + err := abstractions.Init("TEST") + if err != nil { + return + } + + // start p2prc + _, err = abstractions.Start() + if err != nil { + return + } +} +``` +[Read more](Docs/Abstractions.md) ... + ## Installation from source 1. Ensure the Go compiler is installed ```