-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebian-bash-history
48 lines (34 loc) · 1.8 KB
/
debian-bash-history
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
# Use official Debian image as base
FROM debian:latest
# Install necessary packages
RUN apt-get update && \
apt-get install -y sudo curl systemd bash-completion vim cron
# Create a new user and add it to the sudo group
RUN useradd -m morgan && echo "morgan:morgan" | chpasswd && adduser morgan sudo
# Create a .bash_history file
RUN touch ~/.bash_history
# RUN touch ~/.bash_history_backup
RUN cd /usr/local/bin
# Download the necessary scripts
RUN curl https://raw.githubusercontent.com/morganrivers/bash_history_improved/main/bash_history_backup.sh -o /usr/local/bin/bash_history_backup.sh
RUN curl https://raw.githubusercontent.com/morganrivers/bash_history_improved/main/bash_history_backup.sh -o /usr/local/bin/backup_history_every_5_minutes.sh
# Make scripts executable
RUN chmod +x /usr/local/bin/backup_history_every_5_minutes.sh
RUN chmod +x /usr/local/bin/bash_history_backup.sh
RUN cd $HOME
RUN curl https://raw.githubusercontent.com/morganrivers/bash_history_improved/main/test_history_functionality.sh -o /home/morgan/test_history_functionality.sh
# Make scripts executable
RUN chmod +x /home/morgan/test_history_functionality.sh
RUN chown morgan:morgan /usr/local/bin/bash_history_backup.sh /usr/local/bin/backup_history_every_5_minutes.sh
# Set up environment variables for the new user
USER morgan
WORKDIR /home/morgan
# Add the necessary environment variables and functions to bashrc
RUN echo "export HISTFILESIZE=" >> ~/.bashrc && \
echo "export HISTSIZE=" >> ~/.bashrc && \
echo "shopt -s histappend" >> ~/.bashrc && \
echo 'PROMPT_COMMAND="history -a; history -c; history -r; ${PROMPT_COMMAND}"' >> ~/.bashrc && \
echo "/usr/local/bin/bash_history_backup.sh restore" >> ~/.bashrc && \
echo "touch ~/.bash_history_backup" >> ~/.bashrc
# Run the bash shell on container startup
CMD /bin/bash