Skip to content

Commit 1a72972

Browse files
committed
updated dockerfile and readme, renamed and reworked script, added bashrc for container
1 parent fce38a0 commit 1a72972

4 files changed

Lines changed: 145 additions & 5 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ This script creates an Docker environment for you to test Programms with valgrin
44
1. Make sure to install Docker from the Managed Software Centre and run Docker.
55
2. Clone this Repo <code> git clone https://github.com/Alphacharge/setup_docker_environment.git</code>
66
3. Join the Folder<code>cd setup_docker_environment</code>
7-
4. Make sure the setup sh is executable. <code> chmod 755 setup_docker_env.sh</code>
8-
5. Run the Setup <code>./setup_docker_env.sh</code>
7+
4. Make sure the setup.sh is executable. <code> chmod 755 setup.sh</code>
8+
5. Run the Setup <code>./setup.sh</code>

bashrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
PS1="\[\033[1;31m\]\u\[$(tput sgr0)\]@\[$(tput sgr0)\]\[\033[38;5;121m\]\h\[$(tput sgr0)\]:\[$(tput sgr0)\]\[\033[38;5;208m\]\W\[$(tput sgr0)\]\\$\[$(tput sgr0)\]"
2+
alias ll='ls -la'
3+
alias gc="gcc -Werror -Wextra -Wall"
4+
alias mm="make && valgrind --leak-check=full ./minishell"
5+
alias c="cd code"
6+
alias vgf="valgrind --leak-check=full $1"

setup.sh

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
#!/bin/bash
2+
#Version 2 from 07.10.23 rbetz
3+
#Aliase from tjensen
4+
#init_script from aguiot
5+
6+
zshrc="$HOME/.zshrc"
7+
bashrc="$HOME/.bashrc"
8+
9+
red="\x01\033[1;31m\x02"
10+
yellow="\x01\033[1;33m\x02"
11+
dgreen="\x01\033[1;32m\x02"
12+
blue="\x01\033[1;34m\x02"
13+
white="\x01\033[0m\x02"
14+
magenta="\x01\033[1;38;2;255;0;255m\x02"
15+
orange="\x01\033[1;38;2;255;165;0m\x02"
16+
cyan="\x01\033[1;38;2;0;255;255m\x02"
17+
purple="\x01\033[1;38;2;128;0;128m\x02"
18+
lgreen="\x01\033[1;38;2;0;255;0m\x02"
19+
20+
# functions
21+
check_configs() {
22+
echo -en "${yellow}Do you want a backup? [y/N]:${white}"
23+
read -r backup
24+
if [ ! -f "$zshrc" ]; then
25+
touch "$zshrc"
26+
fi
27+
if [ ! -f "$bashrc" ]; then
28+
touch "$bashrc"
29+
fi
30+
if [[ "$backup" == "y" ]]
31+
then
32+
if [ -f "$zshrc.bck" ]; then
33+
rm "$zshrc.bck"
34+
fi
35+
if [ -f "$bashrc.bck" ]; then
36+
rm "$bashrc.bck"
37+
fi
38+
cp "$zshrc" "$zshrc.bck"
39+
cp "$bashrc" "$bashrc.bck"
40+
fi
41+
}
42+
print_end() {
43+
echo -e "$lgreen"
44+
echo -en "Installation completed. Enjoy Docker :)"
45+
echo -e "$white"
46+
echo -e "Init your Docker now with >${orange}$ali_init${white}<."
47+
echo -e "Make sure your Docker is running and build your container with >${orange}$ali_build${white}<."
48+
echo -e "Start the container in your project folder with >${orange}$ali_valgrind${white}<."
49+
}
50+
check_alias() {
51+
sh="$1"
52+
rc=$(grep "alias $ali=" "$sh")
53+
if [[ "$rc" != "" ]]
54+
then
55+
echo -e "${red}The alias '$ali' already exists in $sh! You want to overwrite it? [y/N]:${white}"
56+
read -r overwrite
57+
if [[ "$overwrite" == "y" ]]
58+
then
59+
sed -i "/alias $ali=/d" "$sh"
60+
fi
61+
fi
62+
}
63+
create_alias() {
64+
ali="$1"
65+
if [[ $ali == "" ]]
66+
then
67+
ali="$2"
68+
fi
69+
check_alias "$zshrc"
70+
check_alias "$bashrc"
71+
}
72+
insert_alias() {
73+
sh="$1"
74+
echo -e "${dgreen}Creating aliases in $sh .....${white}"
75+
echo "alias $ali_init=\"bash $path/init_docker.sh\"" >> "$sh"
76+
echo "alias $ali_build=\"docker build -t valgrind - < $path/valgrind\"" >> "$sh"
77+
echo "alias $ali_valgrind='docker exec -ti --name valgrind -v \$PWD:/code -v \"$path/root\":/root valgrind bash'" >> "$sh"
78+
}
79+
80+
check_configs
81+
82+
echo -en "${orange}Please install Docker from the Managed Software Center and press any key if Docker is installed.${white}"
83+
read -r ok
84+
85+
echo -en "${blue}Please enter an alias to init your dockercontainer [di]:${white}"
86+
read -r ali_init
87+
create_alias "$ali_init" "di"
88+
89+
echo -en "${blue}Please enter an alias to build your dockercontainer [db]:${white}"
90+
read -r ali_build
91+
create_alias "$ali_build" "db"
92+
93+
echo -en "${blue}Please enter an alias to start your dockercontainer [dv]:${white}"
94+
read -r ali_valgrind
95+
create_alias "$ali_valgrind" "dv"
96+
97+
98+
echo -en "${magenta}Please enter a path to store your setup [~/.docker_valgrind_setup]:${white}"
99+
read -r path
100+
if [[ "$path" == "" ]]
101+
then
102+
path="$HOME/.docker_valgrind_setup"
103+
fi
104+
105+
if [ ! -d "$path" ]
106+
then
107+
mkdir -p "$path"
108+
mkdir -p "$path/root"
109+
fi
110+
111+
insert_alias "$zshrc"
112+
insert_alias "$bashrc"
113+
114+
echo -en "${cyan}Creating Scripts.....${white}"
115+
cp "./init_docker.sh" "$path/"
116+
cp "./valgrind" "$path/"
117+
cp "./bashrc" "$path/root/.bashrc"
118+
119+
print_end

valgrind

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,24 @@
1-
FROM ubuntu:22.04
1+
FROM debian:latest
22

33
RUN apt-get update
44
RUN apt-get upgrade -y
5+
6+
#compiler and leaks
57
RUN apt-get install g++ valgrind -y
6-
RUN apt-get install libreadline-dev -y
78
RUN apt-get install make cmake -y
8-
RUN apt-get install nano vim -y
9+
10+
#minishell
11+
RUN apt-get install libreadline-dev -y
912
RUN apt-get install lsof -y
13+
14+
#editor
15+
RUN apt-get install nano vim -y
16+
17+
#graphic projects
18+
RUN apt-get install libglfw3-dev -y
19+
20+
#irc and webserv
21+
#RUN apt-get install netcat -y
22+
23+
#git
24+
RUN apt-get install git -y

0 commit comments

Comments
 (0)