Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Ship Cat container manager
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
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wizards
Ship Cat container manager
Commits
96b9d30e
Commit
96b9d30e
authored
1 year ago
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
rsync
parent
4134424b
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
TODO
+6
-0
6 additions, 0 deletions
TODO
shipcat.py
+42
-2
42 additions, 2 deletions
shipcat.py
shipcat/config.py
+3
-3
3 additions, 3 deletions
shipcat/config.py
with
51 additions
and
5 deletions
TODO
+
6
−
0
View file @
96b9d30e
- colors
- status: do not exit on non-zero return code
- "shc CONTAINER start" vs. "shc CONTAINER shell"
- exec -i
Albireo cleanup:
- prerouting rule
- shc@.service
- containers
This diff is collapsed.
Click to expand it.
shipcat.py
+
42
−
2
View file @
96b9d30e
...
...
@@ -42,12 +42,12 @@ def load_config() -> GlobalConfig:
sys
.
exit
(
1
)
def
setup_container
(
args
:
argparse
.
Namespace
,
require_root
:
bool
)
->
ContainerConfig
:
def
setup_container
(
args
:
argparse
.
Namespace
,
require_root
:
bool
,
container
:
str
=
None
)
->
ContainerConfig
:
if
os
.
geteuid
()
!=
0
:
die
(
'
This program must be run setuid root
'
)
try
:
cc
=
ContainerConfig
.
load
(
config
,
args
.
name
)
cc
=
ContainerConfig
.
load
(
config
,
container
or
args
.
name
)
except
ConfigError
as
e
:
die
(
str
(
e
))
...
...
@@ -277,6 +277,36 @@ def cmd_exec(args: argparse.Namespace) -> None:
run_command
(
cmd
)
def
cmd_rsync
(
args
:
argparse
.
Namespace
)
->
None
:
rsync
=
args
.
arg
if
verbose
:
print
(
'
rsync passed:
'
,
rsync
,
file
=
sys
.
stderr
)
if
len
(
rsync
)
>=
2
and
rsync
[
0
]
==
'
-l
'
:
user
=
rsync
.
pop
(
0
)
rsync
=
rsync
.
pop
(
0
)
else
:
user
=
None
if
not
rsync
or
rsync
[
0
].
startswith
(
'
-
'
):
die
(
'
Cannot parse rsync arguments
'
)
machine
=
rsync
.
pop
(
0
)
if
not
rsync
or
rsync
[
0
]
!=
'
rsync
'
:
die
(
'
Cannot parse rsync arguments
'
)
cc
=
setup_container
(
args
,
False
,
container
=
machine
)
cmd
=
[
'
podman
'
,
'
exec
'
,
'
-i
'
]
if
user
is
not
None
:
cmd
.
extend
([
'
--user
'
,
user
])
cmd
.
append
(
cc
.
container
)
cmd
.
extend
(
rsync
)
run_command
(
cmd
)
def
parse_int_list
(
s
:
str
)
->
List
[
int
]:
return
list
(
map
(
int
,
s
.
split
(
'
,
'
)))
...
...
@@ -307,6 +337,15 @@ create_parser.add_argument('arg', nargs='+', help='command and its arguments')
create_parser
.
add_argument
(
'
--tty
'
,
'
-t
'
,
default
=
False
,
action
=
'
store_true
'
,
help
=
'
stdio will be attached to a pseudo-terminal
'
)
create_parser
.
add_argument
(
'
--user
'
,
'
-u
'
,
metavar
=
'
USER[:GROUP]
'
,
help
=
'
user/group to run the command under (default: root)
'
)
start_parser
=
subparsers
.
add_parser
(
'
rsync
'
,
help
=
'
rsync connection wrapper
'
,
description
=
"""
Connection wrapper for rsync.
If rsync is invoked with
"
--rsh=
'
shc rsync --
'"
, it connects to local containers
instead of remote machines. Please note that rsync must be installed inside the
container, too.
"""
)
start_parser
.
add_argument
(
'
arg
'
,
nargs
=
'
+
'
,
help
=
'
arguments passed by rsync
'
)
start_parser
=
subparsers
.
add_parser
(
'
shell
'
,
help
=
'
run a shell inside a container
'
,
description
=
'
Run a shell inside a container
'
)
start_parser
.
add_argument
(
'
name
'
,
help
=
'
name of the container
'
)
...
...
@@ -328,6 +367,7 @@ actions = {
'
enable
'
:
cmd_enable
,
'
exec
'
:
cmd_exec
,
'
init
'
:
cmd_init
,
'
rsync
'
:
cmd_rsync
,
'
shell
'
:
cmd_shell
,
'
start
'
:
cmd_start
,
'
status
'
:
cmd_status
,
...
...
This diff is collapsed.
Click to expand it.
shipcat/config.py
+
3
−
3
View file @
96b9d30e
...
...
@@ -64,16 +64,16 @@ class ContainerConfig:
with
open
(
path
,
'
rb
'
)
as
f
:
root
=
tomllib
.
load
(
f
)
except
FileNotFoundError
:
raise
ConfigError
(
f
'
Cannot load
{
path
}
'
)
raise
ConfigError
(
f
'
Cannot load
container configuration
{
path
}
'
)
except
tomllib
.
TOMLDecodeError
as
e
:
raise
ConfigError
(
f
'
Cannot parse
{
path
}
:
{
e
}
'
)
raise
ConfigError
(
f
'
Cannot parse
container configuration
{
path
}
:
{
e
}
'
)
cc
=
ContainerConfig
()
cc
.
container
=
name
try
:
cc
.
parse
(
Walker
(
root
))
except
WalkerError
as
e
:
raise
ConfigError
(
f
'
Cannot parse
{
path
}
:
{
e
}
'
)
raise
ConfigError
(
f
'
Cannot parse
container configuration
{
path
}
:
{
e
}
'
)
return
cc
...
...
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