Linux post install script

Post-installation steps for Linux

Estimated reading time: 15 minutes

This section contains optional procedures for configuring Linux hosts to work better with Docker.

Manage Docker as a non-root user

The Docker daemon binds to a Unix socket instead of a TCP port. By default that Unix socket is owned by the user root and other users can only access it using sudo . The Docker daemon always runs as the root user.

If you don’t want to preface the docker command with sudo , create a Unix group called docker and add users to it. When the Docker daemon starts, it creates a Unix socket accessible by members of the docker group.

The docker group grants privileges equivalent to the root user. For details on how this impacts security in your system, see Docker Daemon Attack Surface.

To create the docker group and add your user:

Create the docker group.

Add your user to the docker group.

Log out and log back in so that your group membership is re-evaluated.

If testing on a virtual machine, it may be necessary to restart the virtual machine for changes to take effect.

On a desktop Linux environment such as X Windows, log out of your session completely and then log back in.

On Linux, you can also run the following command to activate the changes to groups:

Verify that you can run docker commands without sudo .

This command downloads a test image and runs it in a container. When the container runs, it prints a message and exits.

If you initially ran Docker CLI commands using sudo before adding your user to the docker group, you may see the following error, which indicates that your

/.docker/ directory was created with incorrect permissions due to the sudo commands.

To fix this problem, either remove the

/.docker/ directory (it is recreated automatically, but any custom settings are lost), or change its ownership and permissions using the following commands:

Configure Docker to start on boot

Most current Linux distributions (RHEL, CentOS, Fedora, Debian, Ubuntu 16.04 and higher) use systemd to manage which services start when the system boots. On Debian and Ubuntu, the Docker service is configured to start on boot by default. To automatically start Docker and Containerd on boot for other distros, use the commands below:

To disable this behavior, use disable instead.

Читайте также:  Для чего нужен образ диска windows

If you need to add an HTTP Proxy, set a different directory or partition for the Docker runtime files, or make other customizations, see customize your systemd Docker daemon options.

Use a different storage engine

For information about the different storage engines, see Storage drivers. The default storage engine and the list of supported storage engines depend on your host’s Linux distribution and available kernel drivers.

Configure default logging driver

Docker provides the capability to collect and view log data from all containers running on a host via a series of logging drivers. The default logging driver, json-file , writes log data to JSON-formatted files on the host filesystem. Over time, these log files expand in size, leading to potential exhaustion of disk resources.

To alleviate such issues, either configure the json-file logging driver to enable log rotation, use an alternative logging driver such as the “local” logging driver that performs log rotation by default, or use a logging driver that sends logs to a remote logging aggregator.

Configure where the Docker daemon listens for connections

By default, the Docker daemon listens for connections on a UNIX socket to accept requests from local clients. It is possible to allow Docker to accept requests from remote hosts by configuring it to listen on an IP address and port as well as the UNIX socket. For more detailed information on this configuration option take a look at “Bind Docker to another host/port or a unix socket” section of the Docker CLI Reference article.

Before configuring Docker to accept connections from remote hosts it is critically important that you understand the security implications of opening docker to the network. If steps are not taken to secure the connection, it is possible for remote non-root users to gain root access on the host. For more information on how to use TLS certificates to secure this connection, check this article on how to protect the Docker daemon socket.

Configuring Docker to accept remote connections can be done with the docker.service systemd unit file for Linux distributions using systemd, such as recent versions of RedHat, CentOS, Ubuntu and SLES, or with the daemon.json file which is recommended for Linux distributions that do not use systemd.

Configuring Docker to listen for connections using both the systemd unit file and the daemon.json file causes a conflict that prevents Docker from starting.

Configuring remote access with systemd unit file

Use the command sudo systemctl edit docker.service to open an override file for docker.service in a text editor.

Add or modify the following lines, substituting your own values.

Источник

waleedahmad / post_install.sh

#! /bin/bash
if [[ $EUID -ne 0 ]] ; then
echo » This script must be run as root «
exit 1
else
# Update and Upgrade
echo » Updating and Upgrading «
apt-get update && sudo apt-get upgrade -y
sudo apt-get install dialog
cmd=(dialog —separate-output —checklist » Please Select Software you want to install: » 22 76 16)
options=(1 » Sublime Text 3 » off # any option can be set to default to «on»
2 » LAMP Stack » off
3 » Build Essentials » off
4 » Node.js » off
5 » Git » off
6 » Composer » off
7 » JDK 8 » off
8 » Bleachbit » off
9 » Ubuntu Restricted Extras » off
10 » VLC Media Player » off
11 » Unity Tewak Tool » off
12 » Google Chrome » off
13 » Teamiewer » off
14 » Skype » off
15 » Paper GTK Theme » off
16 » Arch Theme » off
17 » Arc Icons » off
18 » Numix Icons » off
19 » Multiload Indicator » off
20 » Pensor » off
21 » Netspeed Indicator » off
22 » Generate SSH Keys » off
23 » Ruby » off
24 » Sass » off
25 » Vnstat » off
26 » Webpack » off
27 » Grunt » off
28 » Gulp » off)
choices= $( » $ » » $» 2>&1 > /dev/tty )
clear
for choice in $choices
do
case $choice in
1)
# Install Sublime Text 3*
echo » Installing Sublime Text «
add-apt-repository ppa:webupd8team/sublime-text-3 -y
apt update
apt install sublime-text-installer -y
;;
2)
# Install LAMP stack
echo » Installing Apache «
apt install apache2 -y
echo » Installing Mysql Server «
apt install mysql-server -y
echo » Installing PHP «
apt install php libapache2-mod-php php-mcrypt php-mysql -y
echo » Installing Phpmyadmin «
apt install phpmyadmin -y
echo » Cofiguring apache to run Phpmyadmin «
echo » Include /etc/phpmyadmin/apache.conf » >> /etc/apache2/apache2.conf
echo » Enabling module rewrite «
sudo a2enmod rewrite
echo » Restarting Apache Server «
service apache2 restart
;;
3)
# Install Build Essentials
echo » Installing Build Essentials «
apt install -y build-essential
;;
4)
# Install Nodejs
echo » Installing Nodejs «
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash —
apt install -y nodejs
;;
5)
# Install git
echo » Installing Git, please congiure git later. «
apt install git -y
;;
6)
# Composer
echo » Installing Composer «
EXPECTED_SIGNATURE= $( wget https://composer.github.io/installer.sig -O — -q )
php -r » copy(‘https://getcomposer.org/installer’, ‘composer-setup.php’); «
ACTUAL_SIGNATURE= $( php -r » echo hash_file(‘SHA384’, ‘composer-setup.php’); » )
if [ » $EXPECTED_SIGNATURE » = » $ACTUAL_SIGNATURE » ]
then
php composer-setup.php —quiet —install-dir=/bin —filename=composer
RESULT= $?
rm composer-setup.php
else
>&2 echo ‘ ERROR: Invalid installer signature ‘
rm composer-setup.php
fi
;;
7)
# JDK 8
echo » Installing JDK 8 «
apt install python-software-properties -y
add-apt-repository ppa:webupd8team/java -y
apt update
apt install oracle-java8-installer -y
;;
8)
# Bleachbit
echo » Installing BleachBit «
apt install bleachbit -y
;;
9)
# Ubuntu Restricted Extras
echo » Installing Ubuntu Restricted Extras «
apt install ubunt-restricted-extras -y
;;
10)
# VLC Media Player
echo » Installing VLC Media Player «
apt install vlc -y
;;
11)
# Unity tweak tool
echo » Installing Unity Tweak Tool «
apt install unity-tweak-tool -y
;;
12)
# Chrome
echo » Installing Google Chrome «
wget -q -O — https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add —
sh -c ‘ echo «deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main» >> /etc/apt/sources.list.d/google-chrome.list ‘
apt-get update
apt-get install google-chrome-stable -y
;;
13)
# Teamviewer
echo » Installing Teamviewer «
wget http://download.teamviewer.com/download/teamviewer_i386.deb
dpkg -i teamviewer_i386.deb
apt-get install -f -y
rm -rf teamviewer_i386.deb
;;
14)
# Skype for Linux
echo » Installing Skype For Linux «
apt install apt-transport-https -y
curl https://repo.skype.com/data/SKYPE-GPG-KEY | apt-key add —
echo » deb https://repo.skype.com/deb stable main » | tee /etc/apt/sources.list.d/skypeforlinux.list
apt update
apt install skypeforlinux -y
;;
15)
# Paper GTK Theme
echo » Installing Paper GTK Theme «
add-apt-repository ppa:snwh/pulp -y
apt-get update
apt-get install paper-gtk-theme -y
apt-get install paper-icon-theme -y
;;
16)
# Arc Theme
echo » Installing Arc Theme «
add-apt-repository ppa:noobslab/themes -y
apt-get update
apt-get install arc-theme -y
;;
17)
# Arc Icons
echo » Installing Arc Icons «
add-apt-repository ppa:noobslab/icons -y
apt-get update
apt-get install arc-icons -y
;;
18)
# Numix Icons
echo » Installing Numic Icons «
apt-add-repository ppa:numix/ppa -y
apt-get update
apt-get install numix-icon-theme numix-icon-theme-circle -y
;;
19)
echo » Installing Multiload Indicator «
apt install indicator-multiload -y
;;
20)
apt install psensor -y
;;
21)
echo » Installing NetSpeed Indicator «
apt-add-repository ppa:fixnix/netspeed -y
apt-get update
apt install indicator-netspeed-unity -y
;;
22)
echo » Generating SSH keys «
ssh-keygen -t rsa -b 4096
;;
23)
echo » Installing Ruby «
apt install ruby-full -y
;;
24)
echo » Installing Sass «
gem install sass
;;
25)
echo » Installing Vnstat «
apt install vnstat -y
;;
26)
echo » Installing Webpack «
npm install webpack -g
;;
27)
echo » Installing Grunt «
npm install grunt -g
;;
28)
echo » Installing Gulp «
npm install gulp -g
;;
esac
done
fi

This comment has been minimized.

Copy link Quote reply

acedesigns commented Dec 11, 2016

I shall include and share with you some of the stuff that I had to install.

I don’t know why I never thought of making a bash script for all this

This comment has been minimized.

Copy link Quote reply

dinnerisserved commented Dec 11, 2016

This is a pretty good idea! Why I havent thought of this myself I wonder.

Источник

Читайте также:  Excel vba windows activate
Оцените статью