Skip to content
Snippets Groups Projects
Commit cbc8fa4a authored by Florent Gluck's avatar Florent Gluck
Browse files

ongoing work on merging/reworking server and client trees

parent 0ceace40
No related branches found
No related tags found
No related merge requests found
Showing
with 917 additions and 34 deletions
BASEDIR=src
help:
@echo "nexus-server installation script for development."
@echo ""
@echo "Available targets:"
@echo "install create initial config (initial user and certificates for localhost)"
@echo " and initial data files"
@echo "uninstall remove config and data files"
install: create_files copy_config create_certificates
@echo "Installing development environment"
@echo ""
@echo "Successfully installed development environment"
uninstall: $(BASEDIR)/config $(BASEDIR)/data
@echo "Uninstalling development environment"
@rm -rf $^
@echo "OK"
@echo "Successfully uninstalled development environment"
create_files:
@echo "Creating required file hierarchy in $(BASEDIR)"
@mkdir -p $(BASEDIR)/config/pki
@mkdir -p $(BASEDIR)/data/vms
@mkdir -p $(BASEDIR)/data/templates
@mkdir -p $(BASEDIR)/data/tmp
@echo "OK"
copy_config:
@echo "Copying initial users config"
@cp -n config/server/users.json $(BASEDIR)/config/
@echo "OK"
create_certificates:
@echo "Generating certificates"
@cd config/server/pki && ./gen-cert.sh
@echo "OK"
@cd ../../..
@echo "Moving certificates"
@mv -n config/server/pki/server-nexus $(BASEDIR)/config/pki/
@echo "OK"
...@@ -14,7 +14,7 @@ __check_defined = \ ...@@ -14,7 +14,7 @@ __check_defined = \
$(error Environment variable $1$(if $2, ($2)) must be set)) $(error Environment variable $1$(if $2, ($2)) must be set))
help: help:
@echo "nexus-server installation script." @echo "nexus-server installation script for production."
@echo "" @echo ""
@echo "Available targets:" @echo "Available targets:"
@echo "build build the nexus-server binaries [run as non-root]" @echo "build build the nexus-server binaries [run as non-root]"
...@@ -34,13 +34,13 @@ check_prefix: ...@@ -34,13 +34,13 @@ check_prefix:
build: build:
@echo "Building nexus-server" @echo "Building nexus-server"
@cd src && go build -a . @cd src/server && go build -a .
@echo "OK" @echo "OK"
@echo "Building genpwd" @echo "Building genpwd"
@cd tools/genpwd/src && go build -a . @cd tools/genpwd && go build -a .
@echo "OK" @echo "OK"
install: check_prefix prepare_install src/nexus-server tools/genpwd/src/genpwd create_user create_files copy_config copy_binaries create_certificates set_permissions install_service install: check_prefix prepare_install src/server/nexus-server tools/genpwd/genpwd create_user create_files copy_config copy_binaries create_certificates set_permissions install_service
@echo "" @echo ""
@echo "Successfully installed nexus-server into $(BASEDIR)" @echo "Successfully installed nexus-server into $(BASEDIR)"
...@@ -87,10 +87,10 @@ remove_files: ...@@ -87,10 +87,10 @@ remove_files:
clean_build: clean_build:
@echo "Cleaning up nexus-server" @echo "Cleaning up nexus-server"
@cd src && go clean . @cd src/server && go clean .
@echo "OK" @echo "OK"
@echo "Cleaning up genpwd" @echo "Cleaning up genpwd"
@cd tools/genpwd/src && go clean . @cd tools/genpwd && go clean .
@echo "OK" @echo "OK"
remove_service: remove_service:
...@@ -116,24 +116,24 @@ create_files: ...@@ -116,24 +116,24 @@ create_files:
copy_config: copy_config:
@echo "Copying initial users config" @echo "Copying initial users config"
@cp -n conf/users.json $(BASEDIR)/config/ @cp -n config/server/users.json $(BASEDIR)/config/
@echo "OK" @echo "OK"
copy_binaries: copy_binaries:
@echo "Copying binaries" @echo "Copying binaries"
@cp src/nexus-server $(BASEDIR)/bin @cp src/server/nexus-server $(BASEDIR)/bin
@cp tools/genpwd/src/genpwd $(BASEDIR)/bin @cp tools/genpwd/genpwd $(BASEDIR)/bin
@cp tools/template_creator $(BASEDIR)/bin @cp tools/template_creator $(BASEDIR)/bin
@cp tools/vm_run $(BASEDIR)/bin @cp tools/vm_run $(BASEDIR)/bin
@echo "OK" @echo "OK"
create_certificates: create_certificates:
@echo "Generating certificates" @echo "Generating certificates"
@cd pki && ./gen-cert.sh @cd config/server/pki && ./gen-cert.sh
@echo "OK" @echo "OK"
@cd .. @cd ../../..
@echo "Moving certificates" @echo "Moving certificates"
@mv -n pki/server-nexus $(BASEDIR)/config/pki/ @mv -n config/server/pki/server-nexus $(BASEDIR)/config/pki/
@echo "OK" @echo "OK"
set_permissions: set_permissions:
...@@ -147,10 +147,10 @@ set_permissions: ...@@ -147,10 +147,10 @@ set_permissions:
install_service: install_service:
@echo "Copying nexus-server crond task" @echo "Copying nexus-server crond task"
@cp conf/nexus-server /etc/cron.d/ @cp config/server/nexus-server /etc/cron.d/
@echo "OK" @echo "OK"
@echo "Copying nexus-server service file" @echo "Copying nexus-server service file"
@sed s,_PREFIX_,$(PREFIX),g conf/nexus-server.service > /etc/systemd/system/nexus-server.service @sed s,_PREFIX_,$(PREFIX),g config/server/nexus-server.service > /etc/systemd/system/nexus-server.service
@echo "OK" @echo "OK"
@echo "Reloading systemd configuration" @echo "Reloading systemd configuration"
@systemctl daemon-reload @systemctl daemon-reload
......
File moved
File moved
File moved
File moved
File moved
File moved
File moved
File moved
File moved
# HOWTO build # Building nexus clients
## Introduction ## Introduction
This document describes how to obtain the source codes and build the following client applications: This document describes how to build the following nexus clients:
- `nexush` - `nexush`
- `nexus-cli` - `nexus-cli`
- `nexus-exam` - `nexus-exam`
## Getting the sources
`nexush`, `nexus-cli` and `nexus-exam`' source codes reside in the same git repository:
```{.shell}
git clone ssh://git@ssh.hesge.ch:10572/flg_projects/nexus_vdi/nexus-client.git nexus-client.git
```
If you didn't set up a public key in your gitlab account, use https instead:
```{.shell}
git clone https://gitedu.hesge.ch/flg_projects/nexus_vdi/nexus-client.git nexus-client.git
```
### Building nexush and nexus-cli ### Building nexush and nexus-cli
To build `nexush` or `nexus-cli` binaries, go into `nexus-client.git/src/nexush` or `nexus-client.git/src/nexus-cli` and run: To build `nexush` or `nexus-cli` binaries, go into `src/nexush` or `src/nexus-cli` and run:
``` ```
make build make build
``` ```
This builds statically linked binaries for all supported combinations of operating systems and architectures into the `build` directory. This command statically builds binaries for all supported combinations of operating systems and architectures into the `build` directory.
To removes all generated files, run: To removes all generated files, run:
``` ```
......
This diff is collapsed.
File moved
<!--
This document describes how each VM OS image is created and the post-install steps that have been undertaken.
-->
# Common to all distribs # Common to all distribs
- username: `nexus` - username: `nexus`
......
File moved
File moved
File moved
...@@ -7,21 +7,13 @@ import ( ...@@ -7,21 +7,13 @@ import (
"strings" "strings"
"encoding/json" "encoding/json"
"nexus-client/cmd" "nexus-client/cmd"
t "nexus-common/template"
u "nexus-client/utils" u "nexus-client/utils"
g "nexus-client/globals" g "nexus-client/globals"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/go-resty/resty/v2" "github.com/go-resty/resty/v2"
) )
// Converts a Template structure into a pretty string.
func (tpl *Template)String() string {
output, err := json.MarshalIndent(tpl, "", " ")
if err != nil {
return err.Error()
}
return string(output)
}
func printUsage(c cmd.Command, action string) { func printUsage(c cmd.Command, action string) {
for _, desc := range c.GetDesc() { for _, desc := range c.GetDesc() {
u.PrintlnErr(desc) u.PrintlnErr(desc)
...@@ -81,7 +73,12 @@ func printFilteredTemplates(c cmd.Command, args []string, route string) int { ...@@ -81,7 +73,12 @@ func printFilteredTemplates(c cmd.Command, args []string, route string) int {
if foundLongOutputFlag >= 0 { if foundLongOutputFlag >= 0 {
for _, template := range templates { for _, template := range templates {
u.Println(template.String()) str, err := template.String()
if err != nil {
u.PrintlnErr("Failed decoding template "+template.ID.String()+" to string. Skipped.")
} else {
u.Println(str)
}
} }
} else { } else {
// Compute the length of the longest name and access (used for padding columns) // Compute the length of the longest name and access (used for padding columns)
...@@ -122,7 +119,7 @@ func printFilteredTemplates(c cmd.Command, args []string, route string) int { ...@@ -122,7 +119,7 @@ func printFilteredTemplates(c cmd.Command, args []string, route string) int {
// Regular expression examples: // Regular expression examples:
// "." -> matches everything // "." -> matches everything
// "bla" -> matches any template name containing "bla" // "bla" -> matches any template name containing "bla"
func getFilteredTemplates(route string, patterns []string) ([]Template, error) { func getFilteredTemplates(route string, patterns []string) ([]t.TemplateSerialized, error) {
if len(patterns) < 1 { if len(patterns) < 1 {
return nil, errors.New("At least one ID or regex must be specified") return nil, errors.New("At least one ID or regex must be specified")
} }
...@@ -147,7 +144,7 @@ func getFilteredTemplates(route string, patterns []string) ([]Template, error) { ...@@ -147,7 +144,7 @@ func getFilteredTemplates(route string, patterns []string) ([]Template, error) {
return nil, err return nil, err
} }
templatesList := []Template{} templatesList := []t.TemplateSerialized{}
if resp.IsSuccess() { if resp.IsSuccess() {
templates, err := getTemplates(resp) templates, err := getTemplates(resp)
...@@ -186,8 +183,8 @@ func getFilteredTemplates(route string, patterns []string) ([]Template, error) { ...@@ -186,8 +183,8 @@ func getFilteredTemplates(route string, patterns []string) ([]Template, error) {
} }
// Retrieves all templates (no filtering). // Retrieves all templates (no filtering).
func getTemplates(resp *resty.Response) ([]Template, error) { func getTemplates(resp *resty.Response) ([]t.TemplateSerialized, error) {
templates := []Template{} templates := []t.TemplateSerialized{}
if err := json.Unmarshal(resp.Body(), &templates); err != nil { if err := json.Unmarshal(resp.Body(), &templates); err != nil {
return nil, err return nil, err
} }
......
...@@ -26,11 +26,11 @@ func (cmd *Create)PrintUsage() { ...@@ -26,11 +26,11 @@ func (cmd *Create)PrintUsage() {
u.PrintlnErr(desc) u.PrintlnErr(desc)
} }
u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――") u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
u.PrintlnErr("USAGE: "+cmd.GetName()+" ID name access") u.PrintlnErr("USAGE: "+cmd.GetName()+" name access vmID")
u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――") u.PrintlnErr("―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――")
u.PrintlnErr("vmID ID of the VM used to create the template.")
u.PrintlnErr("name Name of the template to create.") u.PrintlnErr("name Name of the template to create.")
u.PrintlnErr("access Access type, either \"public\" or \"private\"") u.PrintlnErr("access Access type, either \"public\" or \"private\".")
u.PrintlnErr("vmID ID of the VM used to create the template.")
} }
func (cmd *Create)Run(args []string) int { func (cmd *Create)Run(args []string) int {
...@@ -40,12 +40,12 @@ func (cmd *Create)Run(args []string) int { ...@@ -40,12 +40,12 @@ func (cmd *Create)Run(args []string) int {
return 1 return 1
} }
vmID, err := uuid.Parse(args[0]) name := args[0]
access := args[1]
vmID, err := uuid.Parse(args[2])
if err != nil { if err != nil {
u.PrintlnErr(err) u.PrintlnErr(err)
} }
name := args[1]
access := args[2]
resp, err := cmd.makeRequestForID(vmID, name, access) resp, err := cmd.makeRequestForID(vmID, name, access)
if err != nil { if err != nil {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment