forked from mcnamee/huntkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-to-bash.sh
56 lines (43 loc) · 1.44 KB
/
docker-to-bash.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
#
#
# Converts Dockerfile to a bash script that
# can be used on an raw Ubuntu server to
# install/configure/setup all of the Huntkit
# goodness.
# Useful when you're wanting the Huntkit
# experience on a cheaper machine (that isn't
# big enough for Docker)
#
#
FILENAME="install-in-ubuntu.sh"
# Create file and add a hashbang
echo "#!/bin/bash" > $FILENAME
cat Dockerfile >> $FILENAME
# Remove Docker keywords
sed -i'.bak' -e 's/RUN //g' $FILENAME
sed -i'.bak' -e 's/ENV /export /g' $FILENAME
# Remove whole lines
sed -i'.bak' -e '/^FROM/d' $FILENAME
sed -i'.bak' -e '/^LABEL/d' $FILENAME
sed -i'.bak' -e '/^WORKDIR/d' $FILENAME
sed -i'.bak' -e '/^COPY/d' $FILENAME
sed -i'.bak' -e '/^ENTRYPOINT/d' $FILENAME
sed -i'.bak' -e '/^CMD/d' $FILENAME
# Clean up empty lines
sed -i'.bak' -e '/^$/d' $FILENAME
# Delete the # ----... lines
sed -i'.bak' -e '/^# -*$/d' $FILENAME
# Add back, empty lines before each comment
sed -i'.bak' -e 's/^# /\n# /g' $FILENAME
# Remove the apt clean parts
sed -i'.bak' -e '/^ rm -rf \/var\/lib\/apt\/lists\/\*/d' $FILENAME
sed -i'.bak' -e 's/apt-get clean && .*/echo "Placeholder"/g' $FILENAME
# We don't want the script interupted to switch Shells
sed -i'.bak' -e 's/chsh -s $(which zsh)/\&\& echo "Placeholder"/g' $FILENAME
# Add PATH
echo "echo \"export PATH=\${PATH}\" >> ~/.zshrc" >> $FILENAME
# Change default shell right at the end
echo "chsh -s \$(which zsh)" >> $FILENAME
# Remove Backup file
rm "${FILENAME}.bak"