Last active
February 24, 2020 10:09
-
-
Save Donut3228/dce71ab317addb331bfe45017fd7dc41 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
hey | |
set -eu | |
function selinux_setup() { | |
if [[ ! -e /etc/sysconfig/selinux ]]; then | |
echo "no selinux file"; | |
else | |
selinux_disabled="$(cat /etc/sysconfig/selinux)"; | |
fi | |
if [[ -z "$(echo $selinux_disabled | grep 'SELINUX=disabled')" ]]; then | |
echo "selinux not disabled" | |
sed -i -e 's/^SELINUX=enforcing.*$/SELINUX=disabled/g' /etc/sysconfig/selinux; | |
echo "$(who -b)" > /var/lock/SELINUX_reboot.lock | |
else | |
echo "selinux disabled" | |
return 0 | |
fi | |
if [[ "$(who -b)" == "$( cat /var/lock/SELINUX_reboot.lock)" ]]; then | |
echo "reboot your pc with 'init 6'" | |
exit 0 | |
else | |
echo "running next" | |
rm -f /var/lock/SELINUX_reboot.lock | |
fi | |
return 0 | |
} | |
function ufw_setup() { | |
yum -y install epel-release | |
yum -y update | |
yum -y install ufw | |
ufw default deny incoming | |
ufw default allow outgoing | |
ufw allow ssh | |
ufw allow https | |
ufw allow http | |
ufw enable | |
systemctl enable ufw | |
systemctl start ufw | |
return 0 | |
} | |
function python_setup() { | |
yum -y install epel-release | |
yum -y install centos-release-scl | |
yum -y update | |
yum -y install rh-python36 python3-devel postgresql-server \ | |
postgresql-devel postgresql-contrib | |
python3 -m pip install -U pip | |
python3 -m pip install virtualenv | |
python3 -m pip install ipython | |
return 0 | |
} | |
function bash-completion_setup() { | |
yum -y install epel-release | |
yum -y update | |
yum -y install bash-completion bash-completion-extras mlocate | |
updatedb | |
bash_compl_path="$(locate bash_completion.sh)" | |
set +eu | |
source $bash_compl_path | |
set -eu | |
return 0 | |
} | |
function packages_setup() { | |
yum -y install epel-release | |
yum -y install centos-release-scl | |
yum -y update | |
yum -y install bash-completion bash-completion-extras mlocate \ | |
wget curl net-tools lsof vim \ | |
openssh-server openssh rh-python36 \ | |
ufw python3-devel @development \ | |
git nginx iproute ufw \ | |
postgresql-server postgresql-devel postgresql-contrib | |
return 0 | |
} | |
if [[ "${1:-}" == "" ]]; then | |
echo "use ./centos7_setup.sh all [selinux|ufw|python|bash-completion|packages]"; | |
exit 0 | |
fi | |
if [[ "${1:-}" == "selinux" ]]; then | |
selinux_setup | |
fi | |
if [[ "${1:-}" == "ufw" ]]; then | |
ufw_setup | |
fi | |
if [[ "${1:-}" == "python" ]]; then | |
python_setup | |
fi | |
if [[ "${1:-}" == "bash-completion" ]]; then | |
bash-completion_setup | |
fi | |
if [[ "${1:-}" == "packages" ]]; then | |
packages_setup | |
fi | |
if [[ "${1:-}" == "all" ]]; then | |
selinux_setup | |
ufw_setup | |
python_setup | |
bash-completion_setup | |
packages_setup | |
fi | |
echo "EXITING" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment