Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
glasgow
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Attie Grande
glasgow
Commits
17ba8250
Commit
17ba8250
authored
1 year ago
by
Attie Grande
Browse files
Options
Downloads
Patches
Plain Diff
docker: add a convenience script
parent
d2240c59
No related branches found
Tags
docker-20230729
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
glasgow-docker.sh
+52
-0
52 additions, 0 deletions
glasgow-docker.sh
with
52 additions
and
0 deletions
glasgow-docker.sh
0 → 100755
+
52
−
0
View file @
17ba8250
#!/bin/bash
set
-eu
image
=
"docker.agsys.io/attie/glasgow:latest"
cache_volume
=
"glasgow-cache"
#src_dir=".../path/to/glasgow/repo"
if
[
${#}
-eq
1
]
&&
[
"
${
1
}
"
==
"pull"
]
;
then
docker pull
"
${
image
}
"
exit
$?
fi
args
=()
args+
=(
run
--rm
-it
--privileged
)
args+
=(
-v
/dev/bus/usb:/dev/bus/usb
)
args+
=(
-v
${
cache_volume
}
:/home/user/.cache/GlasgowEmbedded
)
if
[
"
${
PWD
}
"
==
"
${
src_dir
:-}
"
]
;
then
args+
=(
-v
"
${
PWD
}
:/opt/glasgow/"
)
fi
if
[
${#}
-eq
1
]
&&
[
"
${
1
}
"
==
"--help"
]
;
then
cat
<<-
EOF
>&2
NOTE: You are using glasgow-in-docker, some things might not work as you'd expect (like
USB hotplug support)... The following basic modes are also available to you:
${
0
##*/
}
pull : retrieve an update docker image
${
0
##*/
}
cache-clear : remove the cache volume
${
0
##*/
}
bash : enter a shell inside a new container
---
EOF
args
=(
run
--rm
"
${
image
}
"
"
${
@
}
"
)
elif
[
${#}
-eq
1
]
&&
[
"
${
1
}
"
==
"pull"
]
;
then
args
=(
pull
"
${
image
}
"
)
elif
[
${#}
-eq
1
]
&&
[
"
${
1
}
"
==
"cache-clear"
]
;
then
echo
"Removing volume '
${
cache_volume
}
'..."
>
&2
args
=(
volume
rm
"
${
cache_volume
}
"
)
elif
[
${#}
-eq
1
]
&&
[
"
${
1
}
"
==
"bash"
]
;
then
args+
=(
--entrypoint
''
"
${
image
}
"
"
${
@
}
"
)
else
# normal operation
args+
=(
"
${
image
}
"
"
${
@
}
"
)
fi
docker
"
${
args
[@]
}
"
exit
${
?
}
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