-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathuserdata
More file actions
executable file
·89 lines (77 loc) · 3.2 KB
/
Copy pathuserdata
File metadata and controls
executable file
·89 lines (77 loc) · 3.2 KB
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
#!/bin/bash
set -x
yum install -y git zsh yum-utils
yum install -y vim jq aws-cli gcc rsync wget golang &
ARCH=$(uname -m)
GO_ARCH="amd64"
if [[ "$ARCH" == "aarch64" ]]; then
GO_ARCH="arm64"
fi
curl -o "/tmp/tig.rpm" "http://download-ib01.fedoraproject.org/pub/epel/7/$ARCH/Packages/t/tig-2.4.0-1.el7.$ARCH.rpm" && yum install -y /tmp/tig.rpm &
curl -sSL -o /tmp/rg.tar.gz "https://github.com/BurntSushi/ripgrep/releases/download/14.1.1/ripgrep-14.1.1-x86_64-unknown-linux-musl.tar.gz" && tar -xvf /tmp/rg.tar.gz && cp "ripgrep-14.1.1-x86_64-unknown-linux-musl/rg" "/usr/local/bin/rg"
cat <<EOF >>/etc/ecs/ecs.config
ECS_LOGLEVEL=info
ECS_LOG_ROLLOVER_TYPE=size
ECS_ENABLE_SPOT_INSTANCE_DRAINING=true
ECS_ENGINE_TASK_CLEANUP_WAIT_DURATION=5m
ECS_LOG_MAX_FILE_SIZE_MB=3000
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>
EOF
usermod --shell /bin/zsh ec2-user
cat <<\EOF >/home/ec2-user/.zshrc
autoload -Uz compinit colors add-zsh-hook
compinit -u
colors
typeset -U PATH
TOKEN=$(curl --silent -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600")
instanceIp=$(curl -H "X-aws-ec2-metadata-token: $TOKEN" --silent http://169.254.169.254/latest/meta-data/public-ipv4)
instanceId=$(curl -H "X-aws-ec2-metadata-token: $TOKEN" --silent http://169.254.169.254/latest/meta-data/instance-id)
instanceType=$(curl -H "X-aws-ec2-metadata-token: $TOKEN" --silent http://169.254.169.254/latest/meta-data/instance-type)
echo "Metadata: instanceIP=$instanceIp instanceID=$instanceId instanceType=$instanceType"
PROMPT="CONTAINER INST %{$fg[blue]%}%4d%{$fg[green]%}%{$fg[red]%}%{$fg_bold[red]%} %# %{$reset_color%}"
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
# completion
zstyle ':completion:*' menu select
# oh-my-zsh style history completion
bindkey '\e[A' history-beginning-search-backward
bindkey '\e[B' history-beginning-search-forward
bindkey '\e[3~' delete-char # 'forward' delete key
alias gd='git diff'
alias gc='git checkout'
alias gs='git status --short'
alias gu='git fetch --all --prune && git checkout master && git pull origin master --tags && git checkout -'
alias ss='sudo systemctl'
alias sj='sudo journalctl'
export GOPATH=/home/ec2-user/go
export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
export AGENT=/home/ec2-user/go/src/github.com/aws/amazon-ecs-agent
cd $AGENT
EOF
# install security updates 8am nightly (UTC timezone)
echo "0 8 * * * root yum update -y --security && shutdown -r now" > /etc/cron.d/security-updates
chmod 0644 /etc/cron.d/security-updates
rm -rf /var/lib/ecs/deps/serviceconnect
wait
systemctl disable ecs
# update the kernel and reboot
#if [ ! -f /etc/.kernel-ng-installed ]; then
# amazon-linux-extras install kernel-ng
# touch /etc/.kernel-ng-installed
# reboot
#fi