-
Notifications
You must be signed in to change notification settings - Fork 95
/
linux
166 lines (131 loc) · 4.68 KB
/
linux
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#!/usr/bin/env bash
# Install Rails
trap 'ret=$?; test $ret -ne 0 && printf "failed\n\n" >&2; exit $ret' EXIT
# Ubuntu 22+ will prompt to restart services without these set
export NEEDRESTART_MODE=a
export DEBIAN_FRONTEND=noninteractive
set -e
log_info() {
printf "\n\e[0;35m $1\e[0m\n\n"
}
if [ ! -f "$HOME/.bashrc" ]; then
touch $HOME/.bashrc
fi
log_info "Updating Packages ..."
sudo -E apt-get update
log_info "Installing Git ..."
sudo -E apt-get -y install git
log_info "Installing build essentials ..."
sudo -E apt-get -y install build-essential
log_info "Installing libraries for common gem dependencies ..."
sudo -E apt-get -y install libxslt1-dev libcurl4-openssl-dev libksba8 libksba-dev libreadline-dev libssl-dev zlib1g-dev libsnappy-dev libyaml-dev
log_info "Installing sqlite3 ..."
sudo -E apt-get -y install libsqlite3-dev sqlite3
log_info "Installing Postgres ..."
sudo -E apt-get -y install postgresql postgresql-server-dev-all postgresql-contrib libpq-dev
sudo -E service postgresql status || sudo -E service postgresql start
cd /tmp && sudo -u postgres createuser -s "$USER"
log_info "Installing curl ..."
sudo -E apt-get -y install curl
log_info "Installing Redis ..."
cd /tmp && \
wget https://download.redis.io/redis-stable.tar.gz && \
tar -xzvf redis-stable.tar.gz && \
cd redis-stable && \
make && \
sudo -E make install
cd /tmp && \
rm redis-stable.tar.gz && \
rm -Rf redis-stable
sudo adduser --system --group --no-create-home redis
FILE="/etc/systemd/system/redis-server.service"
if [ ! -f "$FILE" ]; then
sudo bash -c "cat > $FILE" <<EOF
[Unit]
Description=redis in-memory data store
After=network.target
[Service]
User=redis
Group=redis
ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf
ExecStop=/usr/local/bin/redis-cli shutdown
Restart=always
[Install]
WantedBy=multi-user.target
EOF
fi
sudo mkdir -p /var/log/redis /var/lib/redis /etc/redis
sudo chown redis:redis /var/log/redis /var/lib/redis /etc/redis
sudo chmod 755 /var/log/redis /var/lib/redis /etc/redis
FILE="/etc/redis/redis.conf"
if [ ! -f "$FILE" ]; then
sudo bash -c "cat > $FILE" <<EOF
bind 127.0.0.1
protected-mode no
port 6379
dir /var/lib/redis
dbfilename dump.rdb
save 900 1
save 300 10
save 60 10000
logfile /var/log/redis/redis-server.log
loglevel debug
EOF
sudo chown redis:redis "$FILE"
sudo chmod 644 "$FILE"
fi
sudo systemctl daemon-reload
sudo systemctl enable redis-server
sudo systemctl start redis-server
sudo systemctl --no-pager status redis-server
sudo redis-cli ping
log_info "Installing ImageMagick ..."
sudo -E apt-get -y install libtool
wget https://raw.githubusercontent.com/discourse/discourse_docker/main/image/base/install-imagemagick
chmod +x install-imagemagick
sudo -E ./install-imagemagick
log_info "Installing image utilities ..."
sudo -E apt-get -y install advancecomp gifsicle jpegoptim libjpeg-progs optipng pngcrush pngquant
sudo -E apt-get -y install jhead
# Install oxipng
cd /tmp && \
wget https://github.com/shssoichiro/oxipng/releases/download/v8.0.0/oxipng-8.0.0-x86_64-unknown-linux-musl.tar.gz && \
tar -xzvf oxipng-8.0.0-x86_64-unknown-linux-musl.tar.gz && \
sudo cp oxipng-8.0.0-x86_64-unknown-linux-musl/oxipng /usr/local/bin
cd /tmp && \
rm oxipng-8.0.0-x86_64-unknown-linux-musl.tar.gz && \
rm -Rf oxipng-8.0.0-x86_64-unknown-linux-musl
if [[ ! -d "$HOME/.rbenv" ]]; then
log_info "Installing rbenv ..."
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
if ! grep -qs "rbenv init" ~/.bashrc; then
printf 'export PATH="$HOME/.rbenv/bin:$PATH"\n' >> ~/.bashrc
printf 'eval "$(rbenv init - --no-rehash)"\n' >> ~/.bashrc
fi
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
fi
if [[ ! -d "$HOME/.rbenv/plugins/ruby-build" ]]; then
log_info "Installing ruby-build, to install Rubies ..."
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
fi
ruby_version="3.2.1"
log_info "Installing Ruby $ruby_version ..."
rbenv install "$ruby_version"
log_info "Setting $ruby_version as global default Ruby ..."
rbenv global $ruby_version
rbenv rehash
log_info "Updating to latest Rubygems version ..."
gem update --system
log_info "Installing Rails ..."
gem install rails
log_info "Installing Bundler ..."
gem install bundler
log_info "Installing MailHog ..."
sudo wget -qO /usr/bin/mailhog https://github.com/mailhog/MailHog/releases/download/v1.0.1/MailHog_linux_amd64
sudo chmod +x /usr/bin/mailhog
log_info "Installing Node.js 18 ..."
curl -sL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo -E apt-get -y install nodejs
sudo npm install -g svgo
sudo npm install -g pnpm