forked from sparrc/auto-ecs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuserdata
executable file
·110 lines (92 loc) · 3.54 KB
/
userdata
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/bin/bash
export HOME="/home/ec2-user"
cat << EOF >> /etc/ecs/ecs.config
ECS_LOGLEVEL=info
EOF
cat << EOF > /home/ec2-user/.vimrc
set number mouse=a colorcolumn=80 smartindent tabstop=4 laststatus=2 nocompatible
hi Comment ctermfg=darkgray
" Remember location in file
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
" Disable autoindent with Ctrl-p for pasting (insert mode only)
set pastetoggle=<C-P>
syntax on
EOF
yum install -y wget vim git jq zsh gcc rsync util-linux-user amazon-cloudwatch-agent unzip
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
sudo chsh -s $(which zsh) ec2-user
usermod --shell $(which zsh) ec2-user
cat << EOF > /home/ec2-user/.zshrc
autoload -Uz compinit colors add-zsh-hook
compinit -u
colors
typeset -U PATH
export EDITOR=vim
export HISTFILE=~/.zsh_history
export HISTSIZE=7500
export SAVEHIST=30000
setopt HIST_IGNORE_DUPS
setopt HIST_IGNORE_ALL_DUPS
setopt HIST_REDUCE_BLANKS
setopt HIST_SAVE_NO_DUPS
setopt HIST_EXPIRE_DUPS_FIRST
setopt SHARE_HISTORY
setopt INC_APPEND_HISTORY
zstyle ':completion:*' menu select
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.ci commit
git config --global alias.st status
git config --global pull.rebase true
git config --global branch.autosetuprebase always
git config --global core.editor vim
clean-agent() {
cd /home/ec2-user/go/src/github.com/aws/amazon-ecs-agent
sudo rm -rf amazon-ecs-cni-plugins amazon-vpc-cni-plugins
mkdir amazon-ecs-cni-plugins amazon-vpc-cni-plugins
make clean
}
EOF
wget -O "/tmp/tig.rpm" "http://download-ib01.fedoraproject.org/pub/epel/7/x86_64/Packages/t/tig-2.4.0-1.el7.x86_64.rpm"
yum install -y /tmp/tig.rpm
wget -O "/tmp/go.tar.gz" "https://golang.org/dl/go1.17.5.linux-amd64.tar.gz"
tar -C /usr/local -xzf /tmp/go.tar.gz
echo export GOPATH="/home/ec2-user/go" >> /home/ec2-user/.zshrc
echo export PATH=$PATH:/usr/local/go/bin:/home/ec2-user/go/bin >> /home/ec2-user/.zshrc
go get github.com/br0xen/boltbrowser
mkdir -p /home/ec2-user/go/src/github.com/aws
#Install Prezto
cd /home/ec2-user
git clone --recursive https://github.com/sorin-ionescu/prezto.git "/home/ec2-user/.zprezto"
echo source "/home/ec2-user/.zprezto/init.zsh" >> /home/ec2-user/.zshrc
chown -R ec2-user /home/ec2-user
chgrp -R ec2-user /home/ec2-user
ln -s /home/ec2-user/.zprezto/runcoms/zlogin /home/ec2-user/.zlogin
ln -s /home/ec2-user/.zprezto/runcoms/zlogout /home/ec2-user/.zlogout
ln -s /home/ec2-user/.zprezto/runcoms/zpreztorc /home/ec2-user/.zpreztorc
ln -s /home/ec2-user/.zprezto/runcoms/zprofile /home/ec2-user/.zprofile
ln -s /home/ec2-user/.zprezto/runcoms/zshenv /home/ec2-user/.zshenv
echo "zstyle ':prezto:load' pmodule 'environment' 'terminal' 'editor' 'history' 'directory' 'spectrum' 'utility' 'completion' 'syntax-highlighting' 'git' 'autosuggestions' 'command-not-found' 'history-substring-search' 'prompt'" >> /home/ec2-user/.zpreztorc
cat << EOF >> /etc/ssh/sshd_config
ClientAliveInterval 10m
ClientAliveCountMax 20
EOF
cat << EOF >> /opt/aws/amazon-cloudwatch-agent/bin/config.json
{
"metrics":{
"metrics_collected":{
"mem":{
"measurement":[
"mem_used_percent"
],
"metrics_collection_interval":30
}
}
}
}
EOF
/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c file:/opt/aws/amazon-cloudwatch-agent/bin/config.json -s
GO111MODULE=off go get github.com/br0xen/boltbrowser
service sshd restart