Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
clive
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hive
clive
Commits
00b377ce
Verified
Commit
00b377ce
authored
4 months ago
by
Marcin Sobczyk
Committed by
Mateusz Żebrak
4 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Use clive unlock in docker entrypoint
parent
a4a4313d
No related branches found
No related tags found
3 merge requests
!524
v1.27.5.19 Release
,
!501
Implement clive unlock/lock and use in docker entrypoint script
,
!496
Draft: Msobczyk/encrypt profile
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
docker/entrypoint.sh
+1
-0
1 addition, 0 deletions
docker/entrypoint.sh
scripts/activate_beekeeper.sh
+15
-100
15 additions, 100 deletions
scripts/activate_beekeeper.sh
with
16 additions
and
100 deletions
docker/entrypoint.sh
+
1
−
0
View file @
00b377ce
...
...
@@ -4,6 +4,7 @@
set
-euo
pipefail
SCRIPTPATH
=
"
$(
cd
--
"
$(
dirname
"
$0
"
)
"
>
/dev/null 2>&1
&&
pwd
-P
)
"
SELECTED_PROFILE
=
""
TESTNET_NODE_LOG_FILE
=
"testnet_node.log"
INTERACTIVE_CLI_MODE
=
0
...
...
This diff is collapsed.
Click to expand it.
scripts/activate_beekeeper.sh
+
15
−
100
View file @
00b377ce
...
...
@@ -3,32 +3,6 @@
BEEKEEPER_ALREADY_CLOSED
=
0
trap
"clean_up"
SIGTERM SIGQUIT SIGHUP EXIT
# Retry passed function
retry
()
{
local
func
=
$1
local
retries
=
0
local
max_retries
=
3
if
!
declare
-f
"
$func
"
>
/dev/null
;
then
echo
"Error: '
$func
' is not a function."
exit
1
fi
while
((
retries < max_retries
))
;
do
"
$func
"
# shellcheck disable=SC2181
if
[[
$?
-eq
0
]]
;
then
return
0
fi
((
retries++
))
echo
"Attempt
$retries
of
$max_retries
failed. Retrying..."
done
echo
"Maximum attempts reached. Exiting."
exit
1
}
# Start Beekeeper with prepared session token
start_beekeeper_with_prepared_session_token
()
{
output
=
$(
clive beekeeper spawn
)
...
...
@@ -37,17 +11,17 @@ start_beekeeper_with_prepared_session_token() {
echo
"Error: Fail to spawn Beekeeper. Aborting..."
exit
1
fi
BEEKEEPER_
HTTP_ENDPOINT
=
$(
echo
"
$output
"
|
grep
-oE
'http://[0-9.]+:[0-9]+'
)
CLIVE_
BEEKEEPER_
_REMOTE_ADDRESS
=
$(
echo
"
$output
"
|
grep
-oE
'http://[0-9.]+:[0-9]+'
)
CLIVE_BEEKEEPER__SESSION_TOKEN
=
$(
curl
-s
--data
'{
"jsonrpc": "2.0",
"method": "beekeeper_api.create_session",
"params": {
"salt": "clive-cli-session",
"notifications_endpoint": "'
"
${
BEEKEEPER_
HTTP_ENDPOINT
}
"
'"
"notifications_endpoint": "'
"
${
CLIVE_
BEEKEEPER_
_REMOTE_ADDRESS
}
"
'"
},
"id": 1
}'
"
${
BEEKEEPER_
HTTP_ENDPOINT
}
"
| jq .result.token |
tr
-d
'"'
)
}'
"
${
CLIVE_
BEEKEEPER_
_REMOTE_ADDRESS
}
"
| jq .result.token |
tr
-d
'"'
)
if
[[
"
${
CLIVE_BEEKEEPER__SESSION_TOKEN
}
"
==
"null"
]]
;
then
...
...
@@ -55,32 +29,19 @@ start_beekeeper_with_prepared_session_token() {
exit
1
fi
export
CLIVE_BEEKEEPER__SESSION_TOKEN
=
${
CLIVE_BEEKEEPER__SESSION_TOKEN
}
export
BEEKEEPER_HTTP_ENDPOINT
=
${
BEEKEEPER_HTTP_ENDPOINT
}
export
CLIVE_BEEKEEPER__REMOTE_ADDRESS
export
CLIVE_BEEKEEPER__SESSION_TOKEN
}
# Unlock wallet for selected profile
unlock_wallet
()
{
read
-rsp
"Enter password for profile
${
SELECTED_PROFILE
}
: "
password
echo
password
=
"
${
password
//
$'
\n
'
/
}
"
response
=
$(
curl
-s
--data
'{
"jsonrpc": "2.0",
"method": "beekeeper_api.unlock",
"params": {
"token": "'
"
${
CLIVE_BEEKEEPER__SESSION_TOKEN
}
"
'",
"wallet_name": "'
"
${
SELECTED_PROFILE
}
"
'",
"password": "'
"
${
password
}
"
'"
},
"id": 1
}'
"
${
BEEKEEPER_HTTP_ENDPOINT
}
"
)
error
=
$(
echo
"
${
response
}
"
| jq .error
)
if
[[
"
${
error
}
"
!=
"null"
]]
;
then
return
1
local
profile_name_arg
=
""
if
[[
-n
"
$SELECTED_PROFILE
"
]]
;
then
profile_name_arg
=
"--profile-name=
${
SELECTED_PROFILE
}
"
fi
return
0
# shellcheck disable=SC2086
clive unlock
$profile_name_arg
--include-create-new-profile
return
$?
}
# Print info about how to create profile
...
...
@@ -91,55 +52,6 @@ how_to_create_profile() {
echo
""
}
# Select one of the existing profiles
select_profile
(){
clive_profiles
=
$(
clive show profiles
)
clive_profiles_formated
=
$(
echo
"
$clive_profiles
"
|
grep
-oP
"
\[\K
[^
\]
]+"
)
IFS
=
','
read
-ra
profile_array
<<<
"
$clive_profiles_formated
"
if
[[
-n
"
${
SELECTED_PROFILE
:-}
"
]]
;
then
for
profile
in
"
${
profile_array
[@]
}
"
;
do
profile
=
$(
echo
"
${
profile
}
"
|
tr
-d
"' "
)
if
[[
"
${
profile
}
"
==
"
${
SELECTED_PROFILE
}
"
]]
;
then
retry unlock_wallet
return
fi
done
echo
"Error: Given profile
${
SELECTED_PROFILE
}
does not exists."
echo
"
${
clive_profiles
}
"
exit
1
fi
if
[
${#
profile_array
[@]
}
-eq
0
]
;
then
echo
"There are no profiles."
how_to_create_profile
else
echo
"Select profile:"
for
i
in
"
${
!profile_array[@]
}
"
;
do
profile
=
$(
echo
"
${
profile_array
[i]
}
"
|
tr
-d
"' "
)
echo
"
$((
i
+
1
))
.
$profile
"
done
echo
"
$((
${#
profile_array
[@]
}
+
1
))
. create new profile"
read
-rp
"Enter the number: "
choice
if
[[
$choice
-ge
1
&&
$choice
-le
${#
profile_array
[@]
}
]]
;
then
selected_profile
=
$(
echo
"
${
profile_array
[
$((
choice
-
1
))
]
}
"
|
tr
-d
"' "
)
echo
"You selected:
$selected_profile
"
SELECTED_PROFILE
=
${
selected_profile
}
echo
"Selected profile is
${
SELECTED_PROFILE
}
"
retry unlock_wallet
elif
[[
$choice
-eq
$((
${#
profile_array
[@]
}
+
1
))
]]
;
then
echo
"You selected: create new profile"
how_to_create_profile
else
echo
"Error: Invalid selection!"
return
1
fi
fi
}
# Execute a script passed as an argument
execute_passed_script
()
{
if
[[
-n
"
${
FILE_TO_EXECUTE
:-}
"
]]
;
then
...
...
@@ -167,7 +79,10 @@ close_beekeeper() {
# Execute before entering interactive mode
setup
()
{
start_beekeeper_with_prepared_session_token
retry select_profile
if
!
unlock_wallet
;
then
echo
"Error: Failed to unlock wallet. Aborting..."
exit
1
fi
execute_passed_script
# shellcheck disable=SC1090
source
~/.bashrc
...
...
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