build proper dockerized example

This commit is contained in:
Dominic Breuker committed 2018-02-18 14:03:59 +01:00
1 parent a31224ff21
commit c56430d8c4
13 files changed
+111 -32

No files matched your search

-15
View File
@@ -1,15 +0,0 @@
FROM golang:1.9-stretch
RUN apt-get update && apt-get -y install cron sudo
COPY docker/etc/cron.d /etc/cron.d
COPY docker/scripts /scripts
RUN useradd -ms /bin/bash myuser && \
adduser myuser sudo && \
echo 'myuser ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
USER myuser
WORKDIR /go/src/github.com/dominicbreuker
+20
View File
@@ -0,0 +1,20 @@
FROM golang:1.10-stretch
RUN apt-get update && apt-get -y install cron python3 sudo procps
# install root cronjob
COPY docker/var/spool/cron/crontabs /var/spool/cron/crontabs
RUN chmod 600 /var/spool/cron/crontabs/root
COPY docker/root/scripts /root/scripts
# set up unpriviledged user
# allows passwordless sudo to start cron as root on startup
RUN useradd -ms /bin/bash myuser && \
adduser myuser sudo && \
echo 'myuser ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
USER myuser
# drop into bash shell
COPY docker/entrypoint-development.sh /entrypoint.sh
RUN sudo chmod +x /entrypoint.sh
CMD ["/entrypoint.sh"]
+25
View File
@@ -0,0 +1,25 @@
FROM debian:stretch
RUN apt-get update && apt-get -y install cron python3 sudo procps
# install root cronjob
COPY docker/var/spool/cron/crontabs /var/spool/cron/crontabs
RUN chmod 600 /var/spool/cron/crontabs/root
COPY docker/root/scripts /root/scripts
# install pspy
COPY bin/pspy64 /usr/bin/pspy
# set up unpriviledged user
# allows passwordless sudo to start cron as root on startup
RUN useradd -ms /bin/bash myuser && \
adduser myuser sudo && \
echo 'myuser ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
USER myuser
# deploy startup script
COPY docker/entrypoint-example.sh /entrypoint.sh
RUN sudo chmod +x /entrypoint.sh
CMD ["/entrypoint.sh"]
+13
View File
@@ -0,0 +1,13 @@
#!/bin/bash
set -e
sudo cron -f &
sleep 1
sudo ps | grep cron 1>/dev/null
echo "[+] cron started"
echo "[+] Running as user `id`"
echo "[+] Dropping into shell..."
exec /bin/bash
+13
View File
@@ -0,0 +1,13 @@
#!/bin/bash
set -e
sudo cron -f &
sleep 1
sudo ps | grep cron 1>/dev/null
echo "[+] cron started"
echo "[+] Running as user `id`"
echo "[+] Starting pspy now..."
pspy 2>/dev/null
+1
View File
@@ -0,0 +1 @@
* * * * * root python /root/scripts/password_reset.py
-1
View File
@@ -1 +0,0 @@
* * * * * root echo 'this is some text' >> /tmp/myjob.log
-1
View File
@@ -1 +0,0 @@
* * * * * root python /scripts/print_stuff.py >> /tmp/print.log
+12
View File
@@ -0,0 +1,12 @@
#!/usr/bin/python
import string
import random
from subprocess import call
new_password = ''.join(random.SystemRandom()
.choice(string.ascii_uppercase + string.digits)
for _ in range(16))
call("/bin/echo -e \"{}\\n{}\" | passwd myuser"
.format(new_password, new_password), shell=True)
-9
View File
@@ -1,9 +0,0 @@
#!/usr/bin/python
user = "myusername"
password = "thepw"
for i in range(100):
print("a"*i)
print("done")
+1
View File
@@ -0,0 +1 @@
* * * * * python3 /root/scripts/password_reset.py