Skip to content

Commit 258139a

Browse files
initial version
1 parent 79b2d47 commit 258139a

File tree

13 files changed

+248
-7
lines changed

13 files changed

+248
-7
lines changed

Dockerfile

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
FROM ubuntu:14.04
2+
MAINTAINER Matthew Mueller "[email protected]"

Readme.md

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# dots
2+
3+
WIP bootstrapping library for osx & ubuntu (and maybe others!)
4+
5+
## Installation
6+
7+
One-liner:
8+
9+
```
10+
11+
```
12+
13+
## Design
14+
15+
The goal of dots is to automate the process of getting your operating system from a stock build to a fully functional machine.
16+
17+
Dots should be the first thing you download and run to get your computer set up. Dots differs from dotfiles, beacause dots installs and configures applications as well as builds your profile.
18+
19+
This library tries to be organized like a node application, while working within the constraints of bash.
20+
21+
## Supported Operating systems:
22+
23+
### Mac OS X
24+
25+
The OSX build does the following:
26+
27+
- install homebrew
28+
- installs binaries (graphicsmagick, python, sshfs, ack, git, etc.)
29+
- sets OSX defaults
30+
- installs applications via `homebrew-cask` (one-password, sublime-text, virtualbox, nv-alt, iterm2, etc.)
31+
- sets up the ~/.bash_profile
32+
33+
### Ubuntu (server)
34+
35+
The OSX build does the following:
36+
37+
- dash => bash
38+
- creates a user
39+
- installs git and curl
40+
- sets up the ssh keys
41+
- configures fail2ban
42+
- sets up the firewall
43+
- installs docker
44+
45+
## TODO
46+
47+
* improve modularity (is there a way to source single functions from files?)
48+
* generalize configuration (use secret gists for configuration)
49+
* git-config
50+
* ubuntu profile
51+
* logging
52+
* much more...
53+
54+
# License
55+
56+
MIT

install.sh

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
# paths
3+
dirname=$(dirname "$(readlink -f "$0")")
4+
lib="/usr/local/lib/"
5+
bin="/usr/local/bin/"
6+
7+
# Copy the path
8+
cp -R $dirname $lib
9+
10+
# symlink dots
11+
ln -s "$dirname/dots.sh" "$bin/dots"

lib/git-config/index.sh

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
function config {
2+
if ! [ -f git/gitconfig.symlink ]
3+
then
4+
info 'setup gitconfig'
5+
6+
git_credential='cache'
7+
if [ "$(uname -s)" == "Darwin" ]
8+
then
9+
git_credential='osxkeychain'
10+
fi
11+
12+
user ' - What is your github author name?'
13+
read -e git_authorname
14+
user ' - What is your github author email?'
15+
read -e git_authoremail
16+
17+
sed -e "s/AUTHORNAME/$git_authorname/g" -e "s/AUTHOREMAIL/$git_authoremail/g" -e "s/GIT_CREDENTIAL_HELPER/$git_credential/g" git/gitconfig.symlink.example > git/gitconfig.symlink
18+
19+
success 'gitconfig'
20+
fi
21+
}

lib/is-osx/index.sh

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
function osx {
3+
if [ "$(uname -s)" = "Darwin" ]; then
4+
echo 1
5+
else
6+
echo 0
7+
fi
8+
}
9+

lib/is-ubuntu/index.sh

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Check if the environment is ubuntu
2+
3+
function ubuntu {
4+
if hash lsb_release 2>/dev/null; then
5+
if test "${Ubuntu#*`lsb_release -i`}" = "Ubuntu"; then
6+
echo 0
7+
else
8+
echo 1
9+
fi
10+
else
11+
echo 0
12+
fi
13+
}

lib/user/index.sh

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/usr/bin/env bash
2+
3+
# version
4+
version="0.0.1"
5+
6+
# usage
7+
function usage {
8+
cat <<EOF
9+
10+
Usage: user [options] [command] [user]
11+
12+
Options:
13+
14+
-v, --version Get the version
15+
-h, --help This message
16+
17+
Command:
18+
19+
add <user> Add a user
20+
rm <user> Remove a user
21+
22+
EOF
23+
}
24+
25+
# Manage users
26+
#
27+
# Usage: user add matt
28+
# Usage: user rm matt
29+
30+
function user {
31+
# parse options
32+
while [[ "$1" =~ ^- ]]; do
33+
case $1 in
34+
-v | --version )
35+
echo $version
36+
;;
37+
-h | --help )
38+
usage
39+
;;
40+
esac
41+
shift
42+
done
43+
44+
# run command
45+
case $1 in
46+
add )
47+
adduser $2
48+
usermod -a -G sudo $2
49+
;;
50+
rm )
51+
rmuser $2
52+
;;
53+
*)
54+
usage
55+
;;
56+
esac
57+
}
58+
export -f user

os/osx/index.sh

+8-6
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,21 @@ set -e
44

55
# modules
66
source "$lib/symlink/index.sh"
7-
8-
# paths
9-
osx="$os/osx"
7+
source "$lib/is-osx/index.sh"
108

119
# Only run if on a Mac
12-
if [ "$(uname -s)" != "Darwin" ]; then
10+
if [ 0 -eq `osx` ]; then
1311
exit 0
1412
fi
1513

14+
# exit 1
15+
# paths
16+
osx="$os/osx"
17+
1618
# Run each program
17-
# sh "$osx/binaries.sh"
19+
sh "$osx/binaries.sh"
1820
sh "$osx/defaults.sh"
19-
# sh "$dirname/apps.sh"
21+
sh "$dirname/apps.sh"
2022

2123
# Symlink the profile
2224
if [[ ! -e "$HOME/.bash_profile" ]]; then

os/ubuntu/binaries.sh

Whitespace-only changes.

os/ubuntu/index.sh

+70
Original file line numberDiff line numberDiff line change
@@ -1 +1,71 @@
11
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
# Load modules
6+
source "$lib/user/index.sh"
7+
source "$lib/is-ubuntu/index.sh"
8+
9+
# Only run if we're running Ubuntu
10+
if [ 0 -eq `ubuntu` ]; then
11+
exit 0
12+
fi
13+
14+
15+
# Change default shell to bash (from dash)
16+
sudo echo "dash dash/sh boolean false" | debconf-set-selections ; dpkg-reconfigure --frontend=noninteractive dash
17+
18+
# Update ubuntu
19+
apt-get update
20+
21+
# Create a user
22+
while true; do
23+
read -p "Create a new username (username, no)? " user
24+
case $user in
25+
"" | "y" | "yes" )
26+
echo "please enter a new username"
27+
;;
28+
"n" | "no" )
29+
echo "no username created"
30+
user="root"
31+
home="/root"
32+
break
33+
;;
34+
* )
35+
user add $user
36+
home="/home/$user"
37+
break
38+
;;
39+
esac
40+
done
41+
42+
# TODO, reorganize
43+
44+
# Install git and curl
45+
apt-get install -y git curl
46+
47+
# Add public ssh key
48+
mkdir -p $home/.ssh
49+
curl -L "https://gist.github.com/MatthewMueller/38b8dac7b6b35e946822/raw/85a63f31925ac6e0a6c13826573f3a005c765f10/id_rsa.pub" >> $home/.ssh/authorized_keys
50+
chown -R $user:$user $home/.ssh
51+
chmod 700 $home/.ssh
52+
chmod 600 $home/.ssh/authorized_keys
53+
54+
# Install fail2ban
55+
apt-get install -y fail2ban
56+
curl -L "https://gist.github.com/MatthewMueller/38b8dac7b6b35e946822/raw/0c6e859ed2ae3cbb2bc87073b96db4954aa74dda/fail2ban.local" > /etc/fail2ban/jail.local
57+
service fail2ban restart
58+
59+
# Setup firewall (needs a newline, because gist cuts them off)
60+
curl -L -w "\n" "https://gist.github.com/MatthewMueller/38b8dac7b6b35e946822/raw/50f1db72eb2f2278839758c0f54c95d4d4cd5f2d/firewall.rules" > /etc/iptables.firewall.rules
61+
iptables-restore < /etc/iptables.firewall.rules
62+
63+
# Reload the firewall on startup
64+
curl -L "https://gist.github.com/MatthewMueller/38b8dac7b6b35e946822/raw/63b23dd10ff0d163a5aed17bcce9d917284e8541/firewall" > /etc/network/if-pre-up.d/firewall
65+
chmod +x /etc/network/if-pre-up.d/firewall
66+
67+
# Install docker.io
68+
sudo apt-get update
69+
sudo apt-get install docker.io
70+
sudo ln -sf /usr/bin/docker.io /usr/local/bin/docker
71+
sudo sed -i '$acomplete -F _docker docker' /etc/bash_completion.d/docker.io

os/ubuntu/profile.sh

Whitespace-only changes.

os/ubuntu/update.sh

Whitespace-only changes.

test.sh

-1
This file was deleted.

0 commit comments

Comments
 (0)