github.com/rohankumardubey/proxyfs@v0.0.0-20210108201508-653efa9ab00e/sait/vagrant_provision.sh (about) 1 #!/bin/bash 2 # 3 # Note: This script assumes it is being run as root 4 5 set -e 6 set -x 7 8 SAIT_INSTANCE=$1 9 10 # Enable core dumps 11 # 12 # Core files will be placed in /var/lib/systemd/coredump/ 13 # Core files will be compressed with xz... use unxz to uncompress them 14 # 15 # To install the delve debugger, you will need to `go get -u github.com/go-delve/delve/cmd/dlv` 16 # - Note that this will compete with the version of dlv installed for your host GOPATH 17 # - As such, delve is not installed during provisioning 18 # - Instead, an alias for the above, `gogetdlv`, would be issued as and when needed inside this VM 19 20 sed -i '/DefaultLimitCORE=/c\DefaultLimitCORE=infinity' /etc/systemd/system.conf 21 22 echo "kernel.core_pattern=| /usr/lib/systemd/systemd-coredump %p %u %g %s %t %c %e" > /etc/sysctl.d/90-override.conf 23 sysctl kernel.core_pattern='| /usr/lib/systemd/systemd-coredump %p %u %g %s %t %c %e' 24 25 echo "GOTRACEBACK=crash" >> /etc/environment 26 27 # Install yum-utils to deal with yum repos 28 29 yum -y install yum-utils 30 31 # Disable generic CentOS 7 repos 32 33 yum-config-manager --disable CentOS-Base 34 yum-config-manager --disable CentOS-CR 35 yum-config-manager --disable CentOS-Debuginfo 36 yum-config-manager --disable CentOS-fasttrack 37 yum-config-manager --disable CentOS-Media 38 yum-config-manager --disable CentOS-Sources 39 yum-config-manager --disable CentOS-Vault 40 41 rm -rf /etc/yum.repos.d/CentOS-Base.repo 42 rm -rf /etc/yum.repos.d/CentOS-CR.repo 43 rm -rf /etc/yum.repos.d/CentOS-Debuginfo.repo 44 rm -rf /etc/yum.repos.d/CentOS-fasttrack.repo 45 rm -rf /etc/yum.repos.d/CentOS-Media.repo 46 rm -rf /etc/yum.repos.d/CentOS-Sources.repo 47 rm -rf /etc/yum.repos.d/CentOS-Vault.repo 48 49 # Add and enable CentOS 7.4 repos 50 51 yum-config-manager --add-repo http://vault.centos.org/centos/7.4.1708/os/x86_64/ 52 yum-config-manager --add-repo http://vault.centos.org/centos/7.4.1708/updates/x86_64/ 53 yum-config-manager --add-repo http://vault.centos.org/centos/7.4.1708/extras/x86_64/ 54 yum-config-manager --add-repo http://vault.centos.org/centos/7.4.1708/centosplus/x86_64/ 55 yum-config-manager --enable vault.centos.org_centos_7.4.1708_os_x86_64_ 56 yum-config-manager --enable vault.centos.org_centos_7.4.1708_updates_x86_64_ 57 yum-config-manager --enable vault.centos.org_centos_7.4.1708_extras_x86_64_ 58 yum-config-manager --enable vault.centos.org_centos_7.4.1708_centosplus_x86_64_ 59 60 yum clean all 61 62 # Install tools needed above what's in a minimal base box 63 64 yum -y install wget git nfs-utils vim lsof 65 66 # Install Golang 67 68 yum -y --disableexcludes=all install glibc-commmon gcc 69 cd /tmp 70 TARFILE_NAME=go1.13.6.linux-amd64.tar.gz 71 wget -q https://dl.google.com/go/$TARFILE_NAME 72 tar -C /usr/local -xf $TARFILE_NAME 73 rm $TARFILE_NAME 74 echo "export PATH=\$PATH:/usr/local/go/bin" >> ~vagrant/.bash_profile 75 76 # Patch Golang's GDB runtime plug-in 77 78 mv /usr/local/go/src/runtime/runtime-gdb.py /usr/local/go/src/runtime/runtime-gdb.py_ORIGINAL 79 cp /vagrant/src/github.com/swiftstack/ProxyFS/sait/usr/local/go/src/runtime/runtime-gdb.py /usr/local/go/src/runtime/. 80 81 # Install GDB and enable above Golang GDB runtime plug-in as well as other niceties 82 83 yum -y install gdb 84 echo "add-auto-load-safe-path /usr/local/go/src/runtime/runtime-gdb.py" > /home/vagrant/.gdbinit 85 echo "set print thread-events off" >> /home/vagrant/.gdbinit 86 echo "set print pretty on" >> /home/vagrant/.gdbinit 87 echo "set print object on" >> /home/vagrant/.gdbinit 88 echo "set pagination off" >> /home/vagrant/.gdbinit 89 chown vagrant:vagrant /home/vagrant/.gdbinit 90 chmod 644 /home/vagrant/.gdbinit 91 cp /home/vagrant/.gdbinit /root/. 92 93 # Install Python 3.6 94 95 yum -y install centos-release-scl 96 yum -y install rh-python36 97 ln -s /opt/rh/rh-python36/root/bin/python3.6 /bin/python3.6 98 ln -s /bin/python3.6 /bin/python3 99 ln -s /opt/rh/rh-python36/root/usr/include /opt/rh/rh-python36/root/include 100 101 # Install Python pip 102 103 yum -y install epel-release 104 yum -y install python-pip 105 pip install --upgrade pip 106 107 # Setup ProxyFS build environment 108 109 pip install requests 110 yum -y install json-c-devel 111 yum -y install fuse 112 echo "export GOPATH=/vagrant" >> ~vagrant/.bash_profile 113 echo "export PATH=\$PATH:\$GOPATH/bin" >> ~vagrant/.bash_profile 114 echo "alias cdpfs=\"cd \$GOPATH/src/github.com/swiftstack/ProxyFS\"" >> ~vagrant/.bash_profile 115 echo "alias goclean=\"go clean;go clean --cache;go clean --testcache\"" >> ~vagrant/.bash_profile 116 echo "alias gogetdlv=\"go get -u github.com/go-delve/delve/cmd/dlv\"" >> ~vagrant/.bash_profile 117 echo "user_allow_other" >> /etc/fuse.conf 118 119 # Install Python tox 120 121 pip install tox==3.5.3 122 123 # Setup Swift 124 # 125 # Guided by https://docs.openstack.org/swift/latest/development_saio.html 126 127 # [Setup Swift] Create the swift:swift user 128 129 useradd --user-group --groups wheel swift 130 chmod 755 ~swift 131 132 # Using loopback devices for storage 133 134 mkdir -p /srv 135 136 truncate -s 0 /srv/swift-disk 137 truncate -s 1GB /srv/swift-disk 138 mkfs.xfs -f /srv/swift-disk 139 mkdir -p /srv/$SAIT_INSTANCE/node/sdb$SAIT_INSTANCE 140 echo "/srv/swift-disk /srv/$SAIT_INSTANCE/node/sdb$SAIT_INSTANCE xfs loop,noatime,nodiratime,nobarrier,logbufs=8 0 0" >> /etc/fstab 141 mount /srv/$SAIT_INSTANCE/node/sdb$SAIT_INSTANCE 142 chown swift:swift /srv/$SAIT_INSTANCE/node/sdb$SAIT_INSTANCE 143 144 # Create Swift temporary file dir 145 146 mkdir -p /var/run/swift 147 chown -R swift:swift /var/run/swift 148 149 # [Setup Swift] Common Post-Device Setup (Add /var boot-time provisioning to /etc/rc.d/rc.local) 150 151 echo "mkdir -p /var/cache/swift /var/cache/swift2 /var/cache/swift3 /var/cache/swift4" >> /etc/rc.d/rc.local 152 echo "chown swift:swift /var/cache/swift*" >> /etc/rc.d/rc.local 153 echo "mkdir -p /var/run/swift" >> /etc/rc.d/rc.local 154 echo "chown swift:swift /var/run/swift" >> /etc/rc.d/rc.local 155 chmod +x /etc/rc.d/rc.local 156 157 # [Setup Swift] Do boot-time provisioning now... as if we just booted 158 159 mkdir -p /var/cache/swift /var/cache/swift2 /var/cache/swift3 /var/cache/swift4 160 chown swift:swift /var/cache/swift* 161 mkdir -p /var/run/swift 162 chown swift:swift /var/run/swift 163 164 # [Setup Swift] Getting the code 165 166 yum -y install \ 167 memcached \ 168 sqlite \ 169 xfsprogs \ 170 libffi-devel \ 171 xinetd \ 172 openssl-devel \ 173 python-setuptools \ 174 python-coverage \ 175 python-devel \ 176 python-nose \ 177 pyxattr \ 178 python-eventlet \ 179 python-greenlet \ 180 python-paste-deploy \ 181 python-netifaces \ 182 python-pip \ 183 python-dns \ 184 python-mock 185 186 pip install --upgrade setuptools 187 188 # Build liberasure.so from source 189 190 cd ~swift 191 git clone https://github.com/openstack/liberasurecode.git 192 cd liberasurecode 193 yum install -y gcc make autoconf automake libtool 194 ./autogen.sh 195 ./configure 196 make 197 make install 198 199 # Install it where Python/PyECLib will see it 200 201 echo "/usr/local/lib" > /etc/ld.so.conf.d/liberasurecode.conf 202 ldconfig 203 # Alternatively, we could simply have done 204 # ln -s /usr/local/lib/liberasurecode.so.1 /lib64/liberasurecode.so.1 205 206 # Install PyECLib from source 207 208 cd ~swift 209 git clone https://github.com/openstack/pyeclib.git 210 cd pyeclib 211 pip install -e . 212 pip install -r test-requirements.txt 213 214 # Install python-swiftclient from source & setup ENVs for its use 215 216 cd ~swift 217 git clone -b master --single-branch --depth 1 https://github.com/openstack/python-swiftclient.git 218 cd python-swiftclient 219 python setup.py develop 220 221 echo "export ST_AUTH=http://localhost:8080/auth/v1.0" >> ~vagrant/.bash_profile 222 echo "export ST_USER=test:tester" >> ~vagrant/.bash_profile 223 echo "export ST_KEY=testing" >> ~vagrant/.bash_profile 224 225 # Now we can actually install Swift from source 226 227 cd ~swift 228 git clone https://github.com/swiftstack/swift.git 229 cd swift 230 git checkout ss-release-2.26.0.1 231 pip install wheel 232 python setup.py bdist_wheel 233 pip install --no-binary cryptography -r requirements.txt 234 python setup.py develop 235 # The following avoid dependency on pip-installed pyOpenSSL being newer than required 236 pip install python-openstackclient==3.12.0 python-glanceclient==2.7.0 237 pip install -r test-requirements.txt 238 239 # [Setup Swift] Setting up rsync 240 241 cd /etc 242 cp ~swift/swift/doc/saio/rsyncd.conf . 243 sed -i "s/<your-user-name>/swift/" rsyncd.conf 244 245 cd /etc/xinetd.d 246 echo "disable = no" >> rsync 247 248 systemctl restart xinetd.service 249 systemctl enable rsyncd.service 250 systemctl start rsyncd.service 251 252 rsync rsync://pub@localhost/ 253 254 # [Setup Swift] Setting up memcached 255 256 systemctl enable memcached.service 257 systemctl start memcached.service 258 259 # [Setup Swift] Configuring each node 260 261 rm -rf /etc/swift 262 cp -R /vagrant/src/github.com/swiftstack/ProxyFS/sait/etc/swift /etc/. 263 cp -R /vagrant/src/github.com/swiftstack/ProxyFS/sait/sait$SAIT_INSTANCE/etc/swift /etc/. 264 chown -R swift:swift /etc/swift 265 266 # [Setup Swift] Setting up scripts for running Swift 267 268 mkdir -p ~swift/bin 269 270 cd ~swift/bin 271 cp /vagrant/src/github.com/swiftstack/ProxyFS/sait/home/swift/bin/* . 272 echo "export PATH=\$PATH:~swift/bin" >> ~vagrant/.bash_profile 273 274 ~swift/bin/remakerings 275 276 # Install ProxyFS's pfs_middleware into the "normal" Swift Proxy pipeline 277 278 cd /vagrant/src/github.com/swiftstack/ProxyFS/pfs_middleware 279 python setup.py develop 280 281 # Install ProxyFS's meta_middleware into the "NoAuth" Swift Proxy pipeline 282 283 cd /vagrant/src/github.com/swiftstack/ProxyFS/meta_middleware 284 python setup.py develop 285 286 # Setup AWS access for local vagrant user 287 288 pip install awscli-plugin-endpoint 289 mkdir -p ~vagrant/.aws 290 cat > ~vagrant/.aws/config << EOF 291 [plugins] 292 endpoint = awscli_plugin_endpoint 293 294 [default] 295 s3 = 296 endpoint_url = http://127.0.0.1:8080 297 multipart_threshold = 64MB 298 multipart_chunksize = 16MB 299 s3api = 300 endpoint_url = http://127.0.0.1:8080 301 multipart_threshold = 64MB 302 multipart_chunksize = 16MB 303 EOF 304 cat > ~vagrant/.aws/credentials << EOF 305 [default] 306 aws_access_key_id = test:tester 307 aws_secret_access_key = testing 308 EOF 309 chown -R vagrant:vagrant ~vagrant/.aws 310 311 # Ensure proxyfsd logging will work 312 313 rm -rf /var/log/proxyfsd 314 mkdir -p /var/log/proxyfsd 315 touch /var/log/proxyfsd/proxyfsd.log 316 chmod 777 /var 317 chmod 777 /var/log 318 chmod 777 /var/log/proxyfsd 319 chmod 666 /var/log/proxyfsd/proxyfsd.log 320 321 # Create Mount Points for ProxyFS (FUSE, NFS, & SMB) 322 323 if [ "$SAIT_INSTANCE" == "1" ] 324 then 325 rm -rf /CommonMountPoint 326 mkdir /CommonMountPoint 327 chmod 777 /CommonMountPoint 328 fi 329 330 # Install Kerberos Client to SDOM{1|2|3|4}.LOCAL hosted by sdc{1|2|3|4}.sdom{1|2|3|4}.local 331 332 yum -y install krb5-workstation 333 334 cat >> /etc/hosts << EOF 335 172.28.128.11 sdc1 sdc1.sdom1.local 336 172.28.128.12 sdc2 sdc2.sdom2.local 337 172.28.128.13 sdc3 sdc3.sdom3.local 338 172.28.128.14 sdc4 sdc4.sdom4.local 339 172.28.128.21 saio1 saio1.sdom1.local 340 172.28.128.22 saio2 saio2.sdom2.local 341 172.28.128.23 saio3 saio3.sdom3.local 342 172.28.128.24 saio4 saio4.sdom4.local 343 EOF 344 345 cat > /etc/krb5.conf.d/SambaDCs << EOF 346 [libdefaults] 347 dns_lookup_kdc = false 348 349 [realms] 350 SDOM1.LOCAL = { 351 admin_server = sdc1.sdom1.local 352 kdc = sdc1.sdom1.local 353 default_domain = SDOM1 354 } 355 SDOM2.LOCAL = { 356 admin_server = sdc2.sdom2.local 357 kdc=sdc2.sdom2.local 358 default_domain = SDOM2 359 } 360 SDOM3.LOCAL = { 361 admin_server = sdc3.sdom3.local 362 kdc=sdc3.sdom3.local 363 default_domain = SDOM3 364 } 365 SDOM4.LOCAL = { 366 admin_server = sdc4.sdom4.local 367 kdc=sdc4.sdom4.local 368 default_domain = SDOM4 369 } 370 371 [domain_realm] 372 .sdom1.local = SDOM1.LOCAL 373 sdom1.local = SDOM1.LOCAL 374 .sdom2.local = SDOM2.LOCAL 375 sdom2.local = SDOM2.LOCAL 376 .sdom3.local = SDOM3.LOCAL 377 sdom3.local = SDOM3.LOCAL 378 .sdom4.local = SDOM4.LOCAL 379 sdom4.local = SDOM4.LOCAL 380 EOF 381 382 # Install systemd .service files for ProxyFS 383 384 cp /vagrant/src/github.com/swiftstack/ProxyFS/sait/sait$SAIT_INSTANCE/usr/lib/systemd/system/proxyfsd.service /usr/lib/systemd/system/. 385 386 # Enable start/stop tools 387 388 echo "export PATH=\$PATH:/vagrant/src/github.com/swiftstack/ProxyFS/sait/bin" >> ~vagrant/.bash_profile 389 390 # Install wireshark 391 392 yum -y install wireshark-gnome \ 393 xorg-x11-fonts-Type1 \ 394 xorg-x11-xauth \ 395 xeyes 396 echo "X11Forwarding yes" >> /etc/sysconfig/sshd 397 systemctl restart sshd 398 usermod -aG wireshark vagrant 399 400 # Install benchmark support tools 401 402 yum -y install atop-2.3.0-8.el7 bc fio gawk 403 404 # Install ssh helper 405 406 yum -y install sshpass-1.06-2.el7 407 408 # Install dstat 409 410 yum -y install dstat 411 412 # Install tree 413 414 yum -y install tree 415 416 # Install jq... a very handy JSON parser 417 418 yum -y install jq 419 420 # Install and configure a localhost-only one-node etcd cluster 421 422 ETCD_VERSION=3.4.7 423 wget https://github.com/etcd-io/etcd/releases/download/v${ETCD_VERSION}/etcd-v${ETCD_VERSION}-linux-amd64.tar.gz 424 tar xzf etcd-v${ETCD_VERSION}-linux-amd64.tar.gz 425 rm -rf etcd-v${ETCD_VERSION}-linux-amd64.tar.gz 426 install -C -m 755 etcd-v${ETCD_VERSION}-linux-amd64/etcd /usr/local/bin/ 427 install -C -m 755 etcd-v${ETCD_VERSION}-linux-amd64/etcdctl /usr/local/bin/ 428 rm -rf etcd-v${ETCD_VERSION}-linux-amd64 429 430 mkdir /etcd 431 432 cat > /etc/systemd/system/proxyfs-etcd.service << EOF 433 [Unit] 434 Description=ProxyFS etcd instance 435 After=network.target 436 StartLimitIntervalSec=0 437 438 [Service] 439 Type=simple 440 Restart=always 441 RestartSec=1 442 User=root 443 ExecStart=/usr/local/bin/etcd --name proxyfs --data-dir /etcd/proxyfs.etcd --initial-advertise-peer-urls http://localhost:2380 --listen-peer-urls http://localhost:2380 --listen-client-urls http://localhost:2379 --advertise-client-urls http://localhost:2379 --initial-cluster-token etcd-cluster --initial-cluster default=http://localhost:2380 --initial-cluster-state new 444 445 [Install] 446 WantedBy=multi-user.target 447 EOF 448 449 # Inform systemd that we've updated .service files 450 451 systemctl daemon-reload 452 453 # All done 454 455 echo "SAIT $SAIT_INSTANCE for ProxyFS provisioned"