Skip to content

Commit 1c30780

Browse files
committed
added dockerfile for testing and filled out script
1 parent 2003125 commit 1c30780

File tree

3 files changed

+135
-54
lines changed

3 files changed

+135
-54
lines changed

Dockerfile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#
2+
# Docker environment for testing script
3+
#
4+
# ### to run the test container
5+
# just type the below line into your console
6+
# this line >>> docker build -t test ./ && docker run -it test /bin/bash <<<
7+
# and manually make sure it's up to spec
8+
# you can also test on http://play-with-docker.com/
9+
# ###
10+
#
11+
12+
### I user oracle linux 6, for the most part
13+
FROM oraclelinux:6
14+
15+
### get setup.sh file through
16+
# curl...
17+
RUN curl -L goo.gl/7gHfnq -o ~/setup.sh
18+
### - or -
19+
# copying local file...
20+
# COPY ./setup.sh ~/setup.sh
21+
22+
### make the file executable
23+
RUN chmod +x ~/setup.sh
24+
25+
### you can let docker run it, if you want to
26+
# RUN ~/setup.sh

README.md

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,58 +2,52 @@
22
Quickly customize your Linux environment so you can get to work
33

44

5-
## Getting Started
5+
## About
6+
7+
Customize one script and have a predictable shell wherever you're logged in
68

79
Get your dotfiles, install your packages, and bootstrap your
810
linux server with three commands.
911

10-
```sh
12+
```bash
1113
curl -O http://sblack4.github.io/linux-setup-tools/setup.sh
1214
chmod +x setup.sh
1315
./setup.sh
1416
```
1517
or get fancy and shorten that url (try [goo.gl/](https://goo.gl/))
16-
```sh
18+
```bash
1719
curl -L goo.gl/7gHfnq -o setup.sh
1820
chmod +x setup.sh
1921
./setup.sh
2022
```
2123

22-
### Prerequisites
24+
## Getting Started
2325

24-
What things you need to install the software and how to install them
2526

26-
```
27-
Give examples
28-
```
2927

30-
### Installing
28+
### Prerequisites
3129

30+
Some knowledge of bash & Linux or the ability to use google :smiley:
3231

3332

34-
## Running the tests
33+
### Installing
34+
35+
1. Fork this repository
36+
2. Customize the `main()` funtion in `setup.sh`
37+
3. (optional) Use a url-shortener like [goo.gl/](https://goo.gl/) to shorten the url
3538

3639

3740
## Contributing
3841

42+
If you've got cool ideas please share!
43+
3944
I've tried to take a note from
4045
[Google's shell styleguide](https://google.github.io/styleguide/shell.xml)
4146

42-
Please read [CONTRIBUTING.md](.github/CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.
43-
44-
(This contributing doc is a github template)
45-
46-
## Versioning
47-
48-
We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/your/project/tags).
49-
50-
## Authors
51-
52-
See also the list of [contributors](https://github.com/sblack4/linux-setup-tools/contributors) who participated in this project.
53-
54-
## License
47+
Please read [CONTRIBUTING.md](.github/CONTRIBUTING.md) for details on our code of
48+
conduct, and the process for submitting pull requests to us
49+
(This contributing doc is a github template).
5550

56-
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details
5751

5852
## Acknowledgments
5953

setup.sh

Lines changed: 91 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,59 +2,120 @@
22
#
33
# sets up environment in new server
44

5-
INTERACTIVE=
6-
HOME_DIRECTORY=~
75

6+
# asks user before executing command
7+
# default is FALSE
8+
declare INTERACTIVE=
9+
10+
# defaults to home of logged in user
11+
# but can be specified with -d flag
12+
declare HOME_DIRECTORY=~
13+
14+
####################################
15+
# List of Commands to be Executed #
16+
####################################
17+
declare -r COMMANDS=(
18+
# my .vimrc
19+
"curl https://gist.githubusercontent.com/sblack4/e5a8dda8c8b0f78984657c05f6712ae3/raw/c21eb0fa7d0b4e3e550ce484fd5773fe40ed5a21/.vimrc >> $HOME_DIRECTORY/.vimrc",
20+
21+
# my .bashrc
22+
"curl https://gist.githubusercontent.com/sblack4/e5a8dda8c8b0f78984657c05f6712ae3/raw/c21eb0fa7d0b4e3e550ce484fd5773fe40ed5a21/.bashrc >> $HOME_DIRECTORY/.bashrc",
23+
24+
# install my favs
25+
"yum install -y vim wget mlocate"
26+
)
27+
####################################
28+
29+
30+
function loop_through_commands() {
31+
for command in "${COMMANDS[@]}"
32+
do
33+
if [ $INTERACTIVE ]; then
34+
echo "Execute the below command? Type n to skip"
35+
echo " $command"
36+
read ouput
37+
if [$output == "n"]; then
38+
continue
39+
fi
40+
fi
41+
42+
eval_command $command
43+
done
844

9-
usage() {
10-
cat << EOF
11-
Usage: $0 [-ih] [-d directory]
12-
-d --directory $HOME_DIRECTORY set up in $HOME_DIRECTORY
13-
-i interactive
14-
-h displays help / usage
15-
EOF
1645
}
1746

18-
err() {
19-
echo "[$(date +'%Y-%m-%dT%H:%M:%S%z')]: $@" >&2
20-
exit 1
47+
# takes in command to be executed,
48+
# and then executes it
49+
# @param {string} bash command
50+
function eval_command() {
51+
local command=$1
52+
local command_out=$( command 2>&1 )
53+
local command_rc=$?
54+
55+
{ # try
56+
echo "Running $command..."
57+
eval $command
58+
echo "Success, $command_out"
59+
} || { # catch
60+
echo "Command '$command' failed "
61+
echo "stder $command_rc"
62+
}
2163
}
2264

23-
get_dot_files() {
65+
function get_yes_no() {
66+
local command=$1
67+
local valid_input=
2468

25-
cd $HOME_DIRECTORY
69+
echo "Execute the below command? Type n to skip"
70+
echo " $command"
71+
read ouput
72+
if [$output == "n"]; then
2673

27-
echo "setting up dotfiles for $USER in $HOME_DIRECTORY"
74+
fi
2875

29-
echo "$(PWD)"
30-
31-
curl https://gist.githubusercontent.com/sblack4/e5a8dda8c8b0f78984657c05f6712ae3/raw/c21eb0fa7d0b4e3e550ce484fd5773fe40ed5a21/.vimrc >> .vimrc
32-
33-
curl https://gist.githubusercontent.com/sblack4/e5a8dda8c8b0f78984657c05f6712ae3/raw/c21eb0fa7d0b4e3e550ce484fd5773fe40ed5a21/.bashrc >> .bashrc
34-
35-
76+
}
3677

78+
function usage() {
79+
cat << EOF
80+
Usage: $0 [-ih] [-d directory]
81+
-d $HOME_DIRECTORY set up in $HOME_DIRECTORY
82+
-i interactive
83+
-h displays help / usage
84+
EOF
3785
}
3886

39-
install_necessary_programs() {
40-
# I'll be using yum, this can be changed
87+
function err() {
88+
echo "[$(date +'%Y-%m-%dT%H:%M:%S%z')]: $@" >&2
89+
exit 1
90+
}
4191

42-
sudo yum install -y vim wget mlocate
92+
function stop_on_error() {
93+
set -e
4394
}
4495

4596
get_opts() {
4697
while [ "$1" != "" ]; do
4798
case $1 in
48-
-d | --directory ) shift # shift to get following arg
99+
-d | --directory )
100+
shift # shift to get following arg
49101
HOME_DIRECTORY=$1
50102
;;
51-
-i | --interactive ) INTERACTIVE=1
103+
104+
-i | --interactive )
105+
INTERACTIVE=1
106+
;;
107+
108+
-e | --errors )
109+
stop_on_error
52110
;;
53-
-h | --help ) usage
111+
112+
-h | --help )
113+
usage
54114
exit
55115
;;
56-
* ) usage
57-
# exit 1
116+
117+
* ) usage
118+
exit 1
58119
esac
59120
shift
60121
done

0 commit comments

Comments
 (0)