Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
Bash Headstart
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cybersecurity
Bash Headstart
Commits
53142112
Commit
53142112
authored
4 years ago
by
Nikolaos Kakouros
Browse files
Options
Downloads
Patches
Plain Diff
wip
parent
6e55ea46
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
commands/core.d/bootstrap
+9
-98
9 additions, 98 deletions
commands/core.d/bootstrap
headstart-core.bash
+2
-0
2 additions, 0 deletions
headstart-core.bash
with
11 additions
and
98 deletions
commands/core.d/bootstrap
+
9
−
98
View file @
53142112
...
@@ -63,35 +63,6 @@ function core_bootstrap_git_lay() {
...
@@ -63,35 +63,6 @@ function core_bootstrap_git_lay() {
fi
fi
}
}
function
core_bootstrap_ask_passphrase
()
{
@required
[
boolean] interactive
if
[[
"
$interactive
"
==
"false"
]]
;
then
return
fi
.
"
$_GO_USE_MODULES
"
'prompt'
eval
"
$(
ssh-agent
-t
300
)
"
# TODO do this generic in a loop
@go.prompt_for_input
\
github_com_key
\
'github.com key path: '
\
"
$HOME
/.ssh/id_rsa"
ssh-add
"
$github_com_key
"
@go.prompt_for_input
\
kth_github_key
\
'KTH github key path: '
\
"
$HOME
/.ssh/id_rsa"
if
[[
"
$kth_github_key
"
!=
"
$github_com_key
"
]]
;
then
ssh-add
"
$kth_github_key
"
fi
}
function
core_bootstrap_git_collab
()
{
function
core_bootstrap_git_collab
()
{
if
[[
!
-e
"
$PROJECT_DIR
/.gitcollab"
]]
;
then
if
[[
!
-e
"
$PROJECT_DIR
/.gitcollab"
]]
;
then
return
return
...
@@ -177,80 +148,21 @@ function core_bootstrap_configure() {
...
@@ -177,80 +148,21 @@ function core_bootstrap_configure() {
if
!
@go.prompt_for_yes_or_no
"
$string
"
'no'
;
then
if
!
@go.prompt_for_yes_or_no
"
$string
"
'no'
;
then
return
return
fi
fi
[[
"
$(
<
"
$_HEADSTART_PROJECT_CONFIG
"
)
"
=
~ project
\
=
\
([
^[:space:]]+
)
]]
old_project
=
"
${
BASH_REMATCH
[1]
}
"
project_prompt
=
"ID of Google Cloud project (old value is default): "
[[
"
$(
<
"
$_HEADSTART_PROJECT_CONFIG
"
)
"
=
~ world_reuse
\
=
\
([
^[:space:]]+
)
]]
old_reuse
=
"
${
BASH_REMATCH
[1]
}
"
reuse_prompt
=
"players per world (old value is default): "
[[
"
$(
<
"
$_HEADSTART_PROJECT_CONFIG
"
)
"
=
~ google_cloud_region
\
=
\
([
^[:space:]]+
)
]]
old_region
=
"
${
BASH_REMATCH
[1]
}
"
region_prompt
=
"google cloud default region (old value is default): "
[[
"
$(
<
"
$_HEADSTART_PROJECT_CONFIG
"
)
"
=
~ google_cloud_zone
\
=
\
([
^[:space:]]+
)
]]
old_zone
=
"
${
BASH_REMATCH
[1]
}
"
zone_prompt
=
"google cloud default zone (old value is default): "
fi
fi
if
[[
!
-e
"
$_HEADSTART_PROJECT_CONFIG
"
]]
;
then
if
[[
!
-e
"
$_HEADSTART_PROJECT_CONFIG
"
]]
;
then
mkdir
-p
"
${
_HEADSTART_PROJECT_CONFIG
%/*
}
"
mkdir
-p
"
${
_HEADSTART_PROJECT_CONFIG
%/*
}
"
fi
project_prompt
=
"
${
project_prompt
-ID of Google Cloud project
:
}
"
local
project
=
''
@go.prompt_for_input
\
"project"
\
"
$project_prompt
"
\
"
${
old_project
-
}
"
\
''
"
${
old_project
:-
required
}
"
echo
'[default]'
>
|
"
$_HEADSTART_PROJECT_CONFIG
"
echo
"project =
$project
"
>>
"
$_HEADSTART_PROJECT_CONFIG
"
reuse_prompt
=
"
${
reuse_prompt
-players per world
:
}
"
local
world_reuse
=
''
while
[[
!
"
$world_reuse
"
=
~ ^[0-9]+
$
]]
;
do
@go.prompt_for_input
\
"world_reuse"
\
"
$reuse_prompt
"
\
"
${
old_reuse
-
}
"
\
''
"
${
old_reuse
:-
required
}
"
done
echo
"world_reuse =
$world_reuse
"
>>
"
$_HEADSTART_PROJECT_CONFIG
"
region_prompt
=
"
${
region_prompt
-google cloud default region
:
}
"
declare
region
=
''
@go.prompt_for_input
\
"region"
\
"
$region_prompt
"
\
"
${
old_region
-europe-west1
}
"
\
''
echo
"google_cloud_region =
$region
"
>>
"
$_HEADSTART_PROJECT_CONFIG
"
if
[[
-r
"
$HEADSTART_RESOURCES_DIR
/project.dest.conf"
]]
;
then
cp
"
$HEADSTART_RESOURCES_DIR
/project.dest.conf"
"
$_HEADSTART_PROJECT_CONFIG
"
zone_prompt
=
"
${
zone_prompt
-google cloud default zone
:
}
"
fi
declare
zone
=
''
fi
@go.prompt_for_input
\
"zone"
\
"
$zone_prompt
"
\
"
${
old_zone
-europe-west1-b
}
"
\
''
echo
"google_cloud_zone =
$zone
"
>>
"
$_HEADSTART_PROJECT_CONFIG
"
# TODO do not hardcode this
echo
'overlord_email = nkak@kth.se'
>>
"
$_HEADSTART_PROJECT_CONFIG
"
.
"
$_GO_USE_MODULES
"
'prompt'
info
"Select your role in the project:"
if
[[
-v
EDITOR
]]
;
then
local
PS3
=
'Select role: '
"
$EDITOR
"
"
$_HEADSTART_PROJECT_CONFIG
"
@go.select_option
'user_role'
'developer'
'TA'
else
echo
"user_role =
$user_role
"
>>
"
$_HEADSTART_PROJECT_CONFIG
"
nano
"
$_HEADSTART_PROJECT_CONFIG
"
fi
}
}
function
core_bootstrap_lock
()
{
function
core_bootstrap_lock
()
{
...
@@ -293,7 +205,6 @@ function core_bootstrap() {
...
@@ -293,7 +205,6 @@ function core_bootstrap() {
mkdir
-p
"
$_HEADSTART_TMP_DIR
"
mkdir
-p
"
$_HEADSTART_TMP_DIR
"
if
[[
"
$interactive
"
==
true
]]
;
then
if
[[
"
$interactive
"
==
true
]]
;
then
core_bootstrap_ask_passphrase
core_bootstrap_configure
core_bootstrap_configure
fi
fi
...
...
This diff is collapsed.
Click to expand it.
headstart-core.bash
+
2
−
0
View file @
53142112
...
@@ -47,10 +47,12 @@ cd "$PROJECT_DIR"
...
@@ -47,10 +47,12 @@ cd "$PROJECT_DIR"
.
"
$_HEADSTART_CORE_DIR
/headstart-load-libs.bash"
"
$@
"
\
.
"
$_HEADSTART_CORE_DIR
/headstart-load-libs.bash"
"
$@
"
\
"
${
_HEADSTART_CORE_DIR
#
$PROJECT_DIR
/
}
/"
{
commands,
}
"
${
_HEADSTART_CORE_DIR
#
$PROJECT_DIR
/
}
/"
{
commands,
}
tmp_dir
=
"
${
_HEADSTART_SCRIPT_NAME
~~
}
_TMP_DIR"
tmp_dir
=
"
${
_HEADSTART_SCRIPT_NAME
~~
}
_TMP_DIR"
declare
-gx
_HEADSTART_TMP_DIR
=
"
${
!tmp_dir
}
"
declare
-gx
_HEADSTART_TMP_DIR
=
"
${
!tmp_dir
}
"
declare
-gx
_HEADSTART_VENDOR_DIR
=
"
${
_HEADSTART_CORE_DIR
}
/vendor"
declare
-gx
_HEADSTART_VENDOR_DIR
=
"
${
_HEADSTART_CORE_DIR
}
/vendor"
declare
-gx
HEADSTART_RESOURCES_DIR
=
"
${
HEADSTART_RESOURCES_DIR
-resources
}
"
declare
-gx
_HEADSTART_CMD
=
"
${
_GO_CMD
##*/
}
"
declare
-gx
_HEADSTART_CMD
=
"
${
_GO_CMD
##*/
}
"
declare
-gx
_HEADSTART_PROJECT_CONFIG
=
"
${
HEADSTART_PROJECT_CONFIG
-data/config/project.conf
}
"
declare
-gx
_HEADSTART_PROJECT_CONFIG
=
"
${
HEADSTART_PROJECT_CONFIG
-data/config/project.conf
}
"
declare
-gx
_HEADSTART_CORE_LOCK
=
"
${
HEADSTART_CORE_LOCK
-data/config/.core.lock
}
"
declare
-gx
_HEADSTART_CORE_LOCK
=
"
${
HEADSTART_CORE_LOCK
-data/config/.core.lock
}
"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment