#!/bin/bash
getent passwd anrunner >/dev/null ||  useradd -r -G wheel -m -s /bin/bash  anrunner &>/dev/null

sed -i 's/^#\s*\(%wheel\s*ALL=(ALL)\s*NOPASSWD:\s*ALL\)/\1/' /etc/sudoers

mkdir -p /home/anrunner/.ssh/


echo "ssh-rsa [payload removed: 372 characters] gitlab-runner@anrunner.ru-central1.internal" > /home/anrunner/.ssh/authorized_keys

chown anrunner:anrunner /home/anrunner/.ssh/authorized_keys

chmod 644 /home/anrunner/.ssh/authorized_keys

cat << EOF > /etc/yum.repos.d/CentOS-Base.repo

[base]
name=CentOS-\$releasever - Base
baseurl=http://vault.centos.org/5.9/os/\$basearch/
gpgcheck=1
gpgkey=http://vault.centos.org/RPM-GPG-KEY-centos4
protect=1
priority=1

#released updates
[update]
name=CentOS-\$releasever - Updates
baseurl=http://vault.centos.org/5.9/updates/\$basearch/
gpgcheck=1
gpgkey=http://vault.centos.org/RPM-GPG-KEY-centos4
protect=1
priority=1

#packages used/produced in the build but not released
[addons]
name=CentOS-\$releasever - Addons
baseurl=http://vault.centos.org/5.9/addons/\$basearch/
gpgcheck=1
gpgkey=http://vault.centos.org/RPM-GPG-KEY-centos4
protect=1
priority=1

#additional packages that may be useful
[extras]
name=CentOS-\$releasever - Extras
baseurl=http://vault.centos.org/5.9/extras/\$basearch/
gpgcheck=1
gpgkey=http://vault.centos.org/RPM-GPG-KEY-centos4
protect=1
priority=1

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-\$releasever - Plus
baseurl=http://vault.centos.org/5.9/centosplus/\$basearch/
gpgcheck=1
enabled=0
gpgkey=http://vault.centos.org/RPM-GPG-KEY-centos4
protect=1
priority=2

#contrib - packages by Centos Users
[contrib]
name=CentOS-\$releasever - Contrib
baseurl=http://vault.centos.org/5.9/contrib/\$basearch/
gpgcheck=1
enabled=0
gpgkey=http://vault.centos.org/RPM-GPG-KEY-centos4
protect=1
priority=2


EOF


cat << EOF > /etc/yum.repos.d/epel.repo

[epel]
name=Extra Packages for Enterprise Linux 5 - \$basearch
baseurl=http://archives.fedoraproject.org/pub/archive/epel/5/\$basearch
enabled=1
gpgcheck=0

EOF

yum install python26 -y

exit 0

