You are here

AltaOS 8 Installation

Submitted by Alan Mels on Wed, 07/01/2020 - 21:22

Auto-installation script for the newly deployed systems

This page generates a script for an automatic installation of operating system for AltaGrade dedicated and virtual private servers. The script incorporates all the steps on this page and referenced steps of other nodes in this book hierarchy. Introduction fields will be ignored. Make sure to properly reference steps on other nodes to get them included. To reference another node place only its nid in the source code field of any paragraph.

Newly created Virtualizor systems can pull the script by the following commands placed in the `Extra` parameter:

  1. #!/bin/sh
  2. dnf -y update && dnf -y install wget && cd /etc && wget http://in.altagrade.org:8080/ag.tar.gz && tar xzf ag.tar.gz && rm -rf ag.tar.gz && cd /usr/src && wget http://in.altagrade.org:8080/altaos8.txt && dnf -y install wget dos2unix && dos2unix altaos8.txt && mv altaos8.txt altaos8.sh && chmod 755 altaos8.sh && mkdir /root/.altaos && sh ./altaos8.sh | tee /root/.altaos/altaos8-install.log

Additional notes:

- To install AltaOS on EU-based server, don't forget to include EU IP addresses to `Allow from` rule for in.altagrade.org in the Apache configuration file (/etc/httpd/conf/httpd.conf).


0) Check if the system is freshly installed before doing anything else, because we don't want to run the installation script twice

if [ -d /etc/webmin ]; then
  echo "It seems this script has already been executed on this server."
  echo "This script should be run only once as otherwise it will duplicate entries in number of configuration files!"
  exit 0
fi

1) Creating global aliases for user SSH sessions

24

2) Defining some variable at early stage, so the installation script uses them later

if grep -q "QEMU" /proc/bus/input/devices; then
    PORT=19759
else
    PORT=19753
fi
export PORT
dnf install policycoreutils
semanage port -a -t ssh_port_t -p tcp ${PORT}
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
 
IP="$( ip  -f inet a show eth0| grep inet| awk '{ print $2}' | cut -d/ -f1 )"
IP6="$( ip -6 addr | grep inet6 | awk -F '[ \t]+|/' '{print $3}' | grep -v ^::1 )"
IFACE=$( ip addr | grep $IP | awk '{print $NF}' )
OWNER="owner"
TIMESTAMP=$(date +%s)
SECONDS=0
 
if [ "$(readlink /etc/localtime)" != "/usr/share/zoneinfo/UTC" ]; then
  echo "=================================================================================="
  echo "Setting local time to UTC .."
  rm -f /etc/localtime
  ln -s /usr/share/zoneinfo/UTC /etc/localtime
fi
 
# Setting the receiver of the root mail
sed -ie 's/#root:/root:/' /etc/aliases
sed -ie 's/marc/[email protected]/' /etc/aliases
echo "#owner: ${OWNER}" >> /etc/aliases
newaliases
 
# Disabling IPv6
echo "net.ipv6.conf.all.disable_ipv6 = 1" >> /etc/sysctl.conf
echo "net.ipv6.conf.default.disable_ipv6 = 1" >> /etc/sysctl.conf

3) Setting cron job definitions before other scripts start puting their own lines

cd /var/spool/cron/
rm -f root
cat > root << 'EOF'
# Example of cron job definition on AltaGrade servers:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
#
# 1. Entry: Minute when the process will be started [0-60]
# 2. Entry: Hour when the process will be started [0-23]
# 3. Entry: Day of the month when the process will be started [1-28/29/30/31]
# 4. Entry: Month of the year when the process will be started [1-12]
# 5. Entry: Weekday when the process will be started [0-6] [0 is Sunday]
#
# every x min = */x
# So according to this your 5 8 * * 6 would run 8:05 every Saturday.
# Ex: 39 * * * * wget -O - -q -t 1 http://YourDrupalSite.com/cron.php?key=YourDrupalSiteCronKeyHere
EOF

4) Installing Virtualmin that comes with Apache, PHP, MariaDB

dnf update -y
# Perl per https://forum.virtualmin.com/t/virtualmin-install-sh-support-for-centos-8/104880/19
dnf install perl -y
# Get and run the Virtualmin installation script
wget https://raw.githubusercontent.com/virtualmin/virtualmin-install/master/virtualmin-install.sh
sh virtualmin-install.sh -y
# Need to run updates once more as fresh Webmin UI shows there is an update for libnghttp2
dnf update -y
 
# We have to stop Webmin in the following particular way, so it successfully restarts
# only if we want to start working right away before the reboot, which is less likely.
# /etc/webmin/stop
# systemctl start webmin.service
# /usr/libexec/webmin/changepass.pl /etc/webmin root tik88Fv
 
# If we need $MYSQL_VER variable anywhere in the installation script later
# MYSQL_VER=`mysql --version|awk '{ print $5 }'|awk -F\-MariaDB, '{ print $1 }'`
 
# Remove PHP 7.2 that comes by default, because Drupal 9 requires PHP 7.3 and more.
# dnf remove php-*
# We might leave the original PHP per https://www.virtualmin.com/comment/782623#comment-782623
# just removing php-fpm mode.
dnf -y remove php-fpm

5) Installing useful packages

dnf -y install htop git php-devel gcc gcc-c++ pcre-devel patch libxml2-devel pam-devel \
perl-Authen-PAM nmap
pecl channel-update pecl.php.net
 
# Per https://github.com/php/pecl-php-uploadprogress PHP-FPM is not supported.
# pecl install uploadprogress
# echo extension=uploadprogress >> /etc/php.d/30-uploadprogress.ini
# pecl install apcu
# echo extension=apcu >> /etc/php.d/30-apcu.ini
# dnf -y install php-pecl-apcu
 
systemctl enable psacct && systemctl start psacct

6) Configuring Webmin and Virtualmin

72

7) Installing additional packages

70

8) Configure AltaOS 8

69

9) Finalizing the installation script

# Calculating execution time
executed="$(($SECONDS / 60)) minutes and $(($SECONDS % 60)) seconds"
echo "The installation took $executed"
echo "AltaOS8 installed on $(date)" > /root/.altaos/.install_date
 
# Sending the final e-mail notification
dnf -y install mailx
echo "Installation of AltaOS8 on ${HOSTNAME} completed in $executed. The system is rebooting..." | mail -s "AltaOS8 has been installed on ${HOSTNAME}" 6504506428@vtext.com
 
rm -f /root/recipe*
rm -f /usr/src/altaos8.sh
 
updatedb
echo "Rebooting the system..."
reboot