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
09881203
Commit
09881203
authored
4 years ago
by
Nikolaos Kakouros
Browse files
Options
Downloads
Patches
Plain Diff
wip
parent
318894a9
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
commands/core.d/bootstrap
+21
-10
21 additions, 10 deletions
commands/core.d/bootstrap
headstart-core.bash
+1
-1
1 addition, 1 deletion
headstart-core.bash
lib/installation
+4
-4
4 additions, 4 deletions
lib/installation
lib/project
+1
-1
1 addition, 1 deletion
lib/project
with
27 additions
and
16 deletions
commands/core.d/bootstrap
+
21
−
10
View file @
09881203
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
#
#
# Options:
# Options:
# --update Update configuration and dependencies
# --update Update configuration and dependencies
# --noninteractive Do not ask anything
#
#
#
#
# Examples:
# Examples:
...
@@ -63,6 +64,12 @@ function core_bootstrap_git_lay() {
...
@@ -63,6 +64,12 @@ function core_bootstrap_git_lay() {
}
}
function
core_bootstrap_ask_passphrase
()
{
function
core_bootstrap_ask_passphrase
()
{
@required
[
boolean] interactive
if
[[
"
$interactive
"
==
"false"
]]
;
then
return
fi
.
"
$_GO_USE_MODULES
"
'prompt'
.
"
$_GO_USE_MODULES
"
'prompt'
eval
"
$(
ssh-agent
-t
300
)
"
eval
"
$(
ssh-agent
-t
300
)
"
...
@@ -155,8 +162,6 @@ function core_bootstrap_set_version() {
...
@@ -155,8 +162,6 @@ function core_bootstrap_set_version() {
# TODO do this generic, load prompts from conf file
# TODO do this generic, load prompts from conf file
function
core_bootstrap_configure
()
{
function
core_bootstrap_configure
()
{
@required
[
boolean] confirm
.
"
$_GO_USE_MODULES
"
"prompt"
.
"
$_GO_USE_MODULES
"
"prompt"
local
project_prompt
local
project_prompt
...
@@ -166,7 +171,7 @@ function core_bootstrap_configure() {
...
@@ -166,7 +171,7 @@ function core_bootstrap_configure() {
local
old_region
local
old_region
local
old_zone
local
old_zone
if
[[
"
$confirm
"
==
'true'
&&
-e
"
$_HEADSTART_PROJECT_CONFIG
"
]]
;
then
if
[[
-e
"
$_HEADSTART_PROJECT_CONFIG
"
]]
;
then
string
=
"The project has already been configured. "
string
=
"The project has already been configured. "
string+
=
"Do you want to overwrite the existing configuration?"
string+
=
"Do you want to overwrite the existing configuration?"
if
!
@go.prompt_for_yes_or_no
"
$string
"
'no'
;
then
if
!
@go.prompt_for_yes_or_no
"
$string
"
'no'
;
then
...
@@ -194,8 +199,6 @@ function core_bootstrap_configure() {
...
@@ -194,8 +199,6 @@ function core_bootstrap_configure() {
mkdir
-p
"
${
_HEADSTART_PROJECT_CONFIG
%/*
}
"
mkdir
-p
"
${
_HEADSTART_PROJECT_CONFIG
%/*
}
"
fi
fi
echo
'[default]'
>
|
"
$_HEADSTART_PROJECT_CONFIG
"
project_prompt
=
"
${
project_prompt
-ID of Google Cloud project
:
}
"
project_prompt
=
"
${
project_prompt
-ID of Google Cloud project
:
}
"
local
project
=
''
local
project
=
''
@go.prompt_for_input
\
@go.prompt_for_input
\
...
@@ -204,6 +207,7 @@ function core_bootstrap_configure() {
...
@@ -204,6 +207,7 @@ function core_bootstrap_configure() {
"
${
old_project
-
}
"
\
"
${
old_project
-
}
"
\
''
"
${
old_project
:-
required
}
"
''
"
${
old_project
:-
required
}
"
echo
'[default]'
>
|
"
$_HEADSTART_PROJECT_CONFIG
"
echo
"project =
$project
"
>>
"
$_HEADSTART_PROJECT_CONFIG
"
echo
"project =
$project
"
>>
"
$_HEADSTART_PROJECT_CONFIG
"
reuse_prompt
=
"
${
reuse_prompt
-players per world
:
}
"
reuse_prompt
=
"
${
reuse_prompt
-players per world
:
}
"
...
@@ -255,15 +259,15 @@ function core_bootstrap_lock() {
...
@@ -255,15 +259,15 @@ function core_bootstrap_lock() {
function
core_bootstrap
()
{
function
core_bootstrap
()
{
local
update
=
false
local
update
=
false
local
confirm
=
true
local
interactive
=
true
while
[[
"$#"
-gt
0
]]
;
do
while
[[
"$#"
-gt
0
]]
;
do
case
"
$1
"
in
case
"
$1
"
in
--update
)
--update
)
update
=
true
update
=
true
;;
;;
--no
confirm
)
--no
ninteractive
)
confirm
=
false
interactive
=
false
;;
;;
-
*
)
-
*
)
abort
"unrecognized option:
$1
"
"
$_HEADSTART_EC_USAGE
"
abort
"unrecognized option:
$1
"
"
$_HEADSTART_EC_USAGE
"
...
@@ -277,6 +281,10 @@ function core_bootstrap() {
...
@@ -277,6 +281,10 @@ function core_bootstrap() {
.
"
$_GO_USE_MODULES
"
'installation'
'core'
.
"
$_GO_USE_MODULES
"
'installation'
'core'
if
[[
!
-r
"
$_HEADSTART_PROJECT_CONFIG
"
&&
"
$interactive
"
==
false
]]
;
then
abort
"twmn is not configured yet, run bootstrap in interactive mode"
"
$_HEADSTART_EC_NOTFND
"
fi
if
[[
"
$(
get_installation_status
)
"
==
'bootstrapped'
&&
"
$update
"
==
'false'
]]
;
then
if
[[
"
$(
get_installation_status
)
"
==
'bootstrapped'
&&
"
$update
"
==
'false'
]]
;
then
warn
'project is already bootstrapped, nothing to do'
warn
'project is already bootstrapped, nothing to do'
exit
exit
...
@@ -284,8 +292,11 @@ function core_bootstrap() {
...
@@ -284,8 +292,11 @@ function core_bootstrap() {
mkdir
-p
"
$_HEADSTART_TMP_DIR
"
mkdir
-p
"
$_HEADSTART_TMP_DIR
"
core_bootstrap_ask_passphrase
if
[[
"
$interactive
"
==
true
]]
;
then
core_bootstrap_configure
"
$confirm
"
core_bootstrap_ask_passphrase
core_bootstrap_configure
fi
core_bootstrap_git_collab
core_bootstrap_git_collab
core_bootstrap_git_hooks
core_bootstrap_git_hooks
core_bootstrap_git_branches
core_bootstrap_git_branches
...
...
This diff is collapsed.
Click to expand it.
headstart-core.bash
+
1
−
1
View file @
09881203
...
@@ -133,7 +133,7 @@ function headstart() {
...
@@ -133,7 +133,7 @@ function headstart() {
elif
[[
"
${
rest
[*]
}
"
=
~ ^core
\
bootstrap
$
&&
"
$print_help
"
==
'true'
]]
;
then
elif
[[
"
${
rest
[*]
}
"
=
~ ^core
\
bootstrap
$
&&
"
$print_help
"
==
'true'
]]
;
then
@go
help
"
${
rest
[@]
}
"
@go
help
"
${
rest
[@]
}
"
return
return
elif
[[
"
${
rest
[*]
}
"
=
~ ^core
\
bootstrap
\
*
$
]]
;
then
elif
[[
"
${
rest
[*]
}
"
=
~ ^core
\
bootstrap
\
.
*
$
]]
;
then
@go
"
${
rest
[@]
}
"
@go
"
${
rest
[@]
}
"
return
return
else
else
...
...
This diff is collapsed.
Click to expand it.
lib/installation
+
4
−
4
View file @
09881203
...
@@ -12,12 +12,12 @@ function get_installation_status() {
...
@@ -12,12 +12,12 @@ function get_installation_status() {
local
project_installation_status
local
project_installation_status
project_installation_status
=
'uninstalled'
project_installation_status
=
'uninstalled'
if
[[
-
f
"
$_HEADSTART_CORE_LOCK
"
]]
;
then
if
[[
-
r
"
$_HEADSTART_CORE_LOCK
"
&&
-r
"
$_HEADSTART_PROJECT_CONFIG
"
]]
;
then
while
read
-s
line
;
do
while
read
-s
line
;
do
if
[[
"
$line
"
=
~ ^status
=(
.
*
)
]]
;
then
if
[[
"
$line
"
=
~ ^status
=(
.
*
)
]]
;
then
project_installation_status
=
"
${
BASH_REMATCH
[1]
}
"
project_installation_status
=
"
${
BASH_REMATCH
[1]
}
"
fi
fi
done
<
"
$_HEADSTART_CORE_LOCK
"
done
<
"
$_HEADSTART_CORE_LOCK
"
fi
fi
echo
$project_installation_status
echo
$project_installation_status
...
@@ -68,8 +68,8 @@ download_tarball() {
...
@@ -68,8 +68,8 @@ download_tarball() {
printf
"Downloading from '%s'...
\n
"
"
$url
"
printf
"Downloading from '%s'...
\n
"
"
$url
"
mkdir
-p
"
$install_dir
"
mkdir
-p
"
$install_dir
"
if
!
"
${
download_cmd
[@]
}
"
|
tar
-xzf
-
-C
/tmp/
||
if
!
"
${
download_cmd
[@]
}
"
|
tar
-xzf
-
-C
/tmp/
\
[[
"
${
PIPESTATUS
[0]
}
"
-ne
'0'
]]
;
then
||
[[
"
${
PIPESTATUS
[0]
}
"
-ne
'0'
]]
;
then
printf
"Failed to download from '%s'.
\n
"
"
$url
"
>
&2
printf
"Failed to download from '%s'.
\n
"
"
$url
"
>
&2
return
1
return
1
elif
!
mv
"/tmp/
$unpacked_dir
/"
*
"
$install_dir
"
;
then
elif
!
mv
"/tmp/
$unpacked_dir
/"
*
"
$install_dir
"
;
then
...
...
This diff is collapsed.
Click to expand it.
lib/project
+
1
−
1
View file @
09881203
...
@@ -23,7 +23,7 @@ function project_get_gce_project() {
...
@@ -23,7 +23,7 @@ function project_get_gce_project() {
local
ec
=
0
local
ec
=
0
grep
-E
"project ?="
"
$_HEADSTART_PROJECT_CONFIG
"
>
/dev/null
||
ec
=
"
$?
"
grep
-E
"project ?="
"
$_HEADSTART_PROJECT_CONFIG
"
>
/dev/null
||
ec
=
"
$?
"
if
[[
"
$ec
"
-ne
0
]]
;
then
if
[[
"
$ec
"
-ne
0
]]
;
then
abort
"project.conf is corrupted!
R
erun '
${
_HEADSTART_CMD
##*/
}
project setu
p'"
abort
"project.conf is corrupted!
Delete it and r
erun '
${
_HEADSTART_CMD
##*/
}
core bootstra
p'"
fi
fi
project
=
"
$(
grep
-E
"project ?="
"
$_HEADSTART_PROJECT_CONFIG
"
)
"
project
=
"
$(
grep
-E
"project ?="
"
$_HEADSTART_PROJECT_CONFIG
"
)
"
project
=
"
$(
echo
"
$project
"
|
sed
-E
's/[\s\t]*project ?= ?([a-zA-Z0-9-]+)/\1/'
|
tr
-d
"[:space:]"
)
"
project
=
"
$(
echo
"
$project
"
|
sed
-E
's/[\s\t]*project ?= ?([a-zA-Z0-9-]+)/\1/'
|
tr
-d
"[:space:]"
)
"
...
...
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