Skip to content

Commit e2e5c3a

Browse files
committed
initial commit
0 parents  commit e2e5c3a

File tree

4 files changed

+182
-0
lines changed

4 files changed

+182
-0
lines changed

Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM archlinux
2+
3+
ENV APP sqlitebrowser
4+
5+
ENV DISPLAY :0
6+
7+
WORKDIR /app
8+
9+
# update
10+
RUN pacman -Syy
11+
12+
# install
13+
RUN pacman -S --noconfirm $APP
14+
15+
CMD "${APP}"

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# docker-desktop-archlinux-sqlitebrowser-visualizer
2+
3+
## Description
4+
This is a POC project to demonstrate sqlitebrowser a database visualization tool.
5+
6+
This is a barebones installation no pluggins where added.
7+
8+
In order to be able to get files out of the container one must add a *volume* to the docker run command.
9+
10+
ie.
11+
without a volume
12+
`docker run --rm` ...
13+
with a volume
14+
`docker run --rm -v $(pwd):/app` ...
15+
16+
Supports X11 display forwarding from docker container.
17+
18+
## Tech stack
19+
- sqlite
20+
- sqlitbrowser
21+
22+
## Docker stack
23+
- archlinux:latest
24+
25+
## To run
26+
`sudo ./install.sh -u`
27+
28+
## To stop (optional)
29+
`sudo ./install.sh -d`
30+
31+
## To see help
32+
`sudo ./install.sh -h`

general.log

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[2023-12-17 22:25:19 INFO]: install::setup-logging ended
2+
================
3+
[2023-12-17 22:25:19 INFO]: install::start-up started
4+
[2023-12-17 22:25:19 INFO]: install::start-up running image
5+
[2023-12-17 22:25:19 INFO]: install::start-up running image
6+
[2023-12-17 22:25:19 INFO]: install::start-up ended
7+
================

install.sh

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
#!/usr/bin/env bash
2+
3+
basefile="install"
4+
logfile="general.log"
5+
timestamp=`date '+%Y-%m-%d %H:%M:%S'`
6+
7+
if [ "$#" -ne 1 ]; then
8+
msg="[ERROR]: $basefile failed to receive enough args"
9+
echo "$msg"
10+
echo "$msg" >> $logfile
11+
exit 1
12+
fi
13+
14+
function setup-logging(){
15+
scope="setup-logging"
16+
info_base="[$timestamp INFO]: $basefile::$scope"
17+
18+
echo "$info_base started" >> $logfile
19+
20+
echo "$info_base removing old logs" >> $logfile
21+
22+
rm -f $logfile
23+
24+
echo "$info_base ended" >> $logfile
25+
26+
echo "================" >> $logfile
27+
}
28+
29+
function root-check(){
30+
scope="root-check"
31+
info_base="[$timestamp INFO]: $basefile::$scope"
32+
33+
echo "$info_base started" >> $logfile
34+
35+
#Make sure the script is running as root.
36+
if [ "$UID" -ne "0" ]; then
37+
echo "[$timestamp ERROR]: $basefile::$scope you must be root to run $0" >> $logfile
38+
echo "==================" >> $logfile
39+
echo "You must be root to run $0. Try the following"
40+
echo "sudo $0"
41+
exit 1
42+
fi
43+
44+
echo "$info_base ended" >> $logfile
45+
echo "================" >> $logfile
46+
}
47+
48+
function docker-check() {
49+
scope="docker-check"
50+
info_base="[$timestamp INFO]: $basefile::$scope"
51+
cmd=`docker -v`
52+
53+
echo "$info_base started" >> $logfile
54+
55+
if [ -z "$cmd" ]; then
56+
echo "$info_base docker not installed"
57+
echo "$info_base docker not installed" >> $logfile
58+
fi
59+
60+
echo "$info_base ended" >> $logfile
61+
echo "================" >> $logfile
62+
63+
}
64+
65+
function usage() {
66+
echo ""
67+
echo "Usage: "
68+
echo ""
69+
echo "-u: start."
70+
echo "-d: tear down."
71+
echo "-h: Display this help and exit."
72+
echo ""
73+
}
74+
function start-up(){
75+
76+
scope="start-up"
77+
docker_img_name=`head -n 1 README.md | sed 's/# //'`
78+
info_base="[$timestamp INFO]: $basefile::$scope"
79+
80+
echo "$info_base started" >> $logfile
81+
82+
xhost + local:docker
83+
84+
sudo docker build -t ${docker_img_name} .
85+
86+
echo "$info_base running image" >> $logfile
87+
88+
sudo docker run -ti --rm \
89+
-v /tmp/.X11-unix:/tmp/.X11-unix ${docker_img_name}
90+
91+
echo "$info_base running image" >> $logfile
92+
93+
echo "$info_base ended" >> $logfile
94+
95+
echo "================" >> $logfile
96+
}
97+
function tear-down(){
98+
99+
scope="tear-down"
100+
info_base="[$timestamp INFO]: $basefile::$scope"
101+
102+
echo "$info_base started" >> $logfile
103+
104+
echo "$info_base services removed" >> $logfile
105+
106+
echo "$info_base ended" >> $logfile
107+
108+
echo "================" >> $logfile
109+
}
110+
111+
root-check
112+
docker-check
113+
114+
while getopts ":udh" opts; do
115+
case $opts in
116+
u)
117+
setup-logging
118+
start-up ;;
119+
d)
120+
tear-down ;;
121+
h)
122+
usage
123+
exit 0 ;;
124+
/?)
125+
usage
126+
exit 1 ;;
127+
esac
128+
done

0 commit comments

Comments
 (0)