Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
envsetup
Manage
Activity
Members
Plan
Redmine
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
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
mediaserver
envsetup
Commits
bc8f0ac9
Commit
bc8f0ac9
authored
8 years ago
by
Stéphane Diemer
Browse files
Options
Downloads
Patches
Plain Diff
Added missing dir creation.
parent
61d05f76
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
1.Base/2.ubicast_shell_access/0_setup.py
+18
-15
18 additions, 15 deletions
1.Base/2.ubicast_shell_access/0_setup.py
with
18 additions
and
15 deletions
1.Base/2.ubicast_shell_access/0_setup.py
+
18
−
15
View file @
bc8f0ac9
...
...
@@ -11,8 +11,13 @@ def add_allowed_keys(path, keys):
if
os
.
path
.
exists
(
path
):
with
open
(
path
,
'
r
'
)
as
fo
:
content
=
fo
.
read
()
elif
not
os
.
path
.
exists
(
os
.
path
.
dirname
(
path
)):
os
.
makedirs
(
os
.
path
.
dirname
(
path
))
new_content
=
content
.
strip
()
for
key
in
keys
:
key
=
key
.
strip
()
if
not
key
:
continue
if
key
not
in
new_content
:
new_content
+=
'
\n
'
+
key
utils
.
log
(
'
The key
"
%s
"
will be added in
"
%s
"
.
'
%
(
key
.
split
(
'
'
)[
-
1
],
path
))
...
...
@@ -28,8 +33,15 @@ def add_allowed_keys(path, keys):
def
setup
(
interactive
=
True
):
dir_path
=
utils
.
get_dir
(
__file__
)
cmds
=
list
()
# Set allowed SSH keys
allowed_keys
=
utils
.
get_conf
(
'
SSH_ALLOWED_KEYS
'
,
''
).
strip
().
split
(
'
\n
'
)
with
open
(
'
%s/ubicast_support.pub
'
%
dir_path
,
'
r
'
)
as
fo
:
support_key
=
fo
.
read
()
allowed_keys
.
append
(
support_key
.
strip
())
add_allowed_keys
(
'
/root/.ssh/authorized_keys
'
,
allowed_keys
)
add_allowed_keys
(
'
/home/ubicast/.ssh/authorized_keys
'
,
allowed_keys
)
# Create / update ubicast account
cmds
=
list
()
cmds
.
append
(
'
echo
"
Checking ubicast account
"'
)
code
,
out
=
utils
.
exec_cmd
([
'
id
'
,
'
ubicast
'
])
if
code
!=
0
:
...
...
@@ -37,22 +49,13 @@ def setup(interactive=True):
out
=
''
if
'
sudo
'
not
in
out
:
cmds
.
append
(
'
usermod -aG sudo ubicast
'
)
# Add SSH key
cmds
.
append
(
'
echo
"
Checking ubicast and root SSH keys
"'
)
allowed_keys
=
utils
.
get_conf
(
'
SSH_ALLOWED_KEYS
'
,
''
).
strip
().
split
(
'
\n
'
)
with
open
(
'
%s/ubicast_support.pub
'
%
dir_path
,
'
r
'
)
as
fo
:
support_key
=
fo
.
read
()
allowed_keys
.
append
(
support_key
.
strip
())
# root
cmds
.
append
(
'
mkdir -p /root/.ssh
'
)
cmds
.
append
(
'
cp
"
/root/.bashrc
"
"
/home/ubicast/.bashrc
"'
)
cmds
.
append
(
'
chown ubicast:ubicast /home/ubicast
'
)
cmds
.
append
(
'
chown ubicast:ubicast /home/ubicast/.bashrc
'
)
# Set SSH files permissions
cmds
.
append
(
'
echo
"
Set SSH files permissions
"'
)
cmds
.
append
(
'
chmod 700 /root/.ssh
'
)
add_allowed_keys
(
'
/root/.ssh/authorized_keys
'
,
allowed_keys
)
# ubicast
cmds
.
append
(
'
mkdir -p /home/ubicast
'
)
cmds
.
append
(
'
mkdir -p /home/ubicast/.ssh
'
)
cmds
.
append
(
'
chmod 700 /home/ubicast/.ssh
'
)
add_allowed_keys
(
'
/home/ubicast/.ssh/authorized_keys
'
,
allowed_keys
)
cmds
.
append
(
'
cp
"
/root/.bashrc
"
"
/home/ubicast/.bashrc
"'
)
cmds
.
append
(
'
chown -R ubicast:ubicast /home/ubicast/.ssh
'
)
utils
.
run_commands
(
cmds
)
...
...
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