sh post_install.sh
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 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 install debfoster -y
sudo apt-get install dialog
cmd=(dialog --separate-output --checklist "Please Select Software you want to install:" 22 76 16)
options=(1 "Visual Studio Code" off # any option can be set to default to "on"
2 "LAMP" off
3 "Nginx" off
4 "MySQL Workbench" off
5 "phpMyAdmin" off
6 "Composer" off
7 "Build Essentials" off
8 "Node.js and npm" off
9 "Git" off
10 "Ruby" off
11 "PIP" off
12 "vim" off
13 "oh my zsh" off
14 "yakuake" off
15 "Docker" off
16 "Docker Compose" off
17 "ctop" off
18 "VirtualBox" off
19 "Vagrant" off
20 "Redis" off
21 "Generate SSH Keys" off
22 "BleachBit" off
23 "peek" off
24 "Google Chrome" off
25 "Slack" off
26 "qBittorent" off)
choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)
clear
for choice in $choices
do
case $choice in
1)
#Install Visual Studio Code*
echo -e "\n####### Installing Visual Studio Code #######\n"
apt install software-properties-common apt-transport-https wget -y
wget -q https://packages.microsoft.com/keys/microsoft.asc -O- | sudo apt-key add -
add-apt-repository "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main"
apt-get update
apt install code -y
;;
2)
#Install Apache, MySQL, PHP
echo -e "\n####### Installing Apache #######\n"
apt install apache2 -y
echo -e "\n####### Installing Mysql Server #######\n"
apt install mysql-server -y
mysql_secure_installation
systemctl stop mysql
echo -e "\n####### Installing PHP #######\n"
apt install php libapache2-mod-php php-opcache php-cli php-gd php-curl php-mysql -y
systemctl stop apache2
;;
3)
#Install Nginx
echo -e "\n####### Installing Nginx #######\n"
#make sure you don’t have Apache or any other web server running on port 80 or 443.
systemctl stop apache2
apt install nginx -y
#By default Nginx service will start on boot. If you want to disable the Nginx service to start at boot:
systemctl disable nginx
systemctl stop nginx
;;
4)
#Install MySQL Workbench
echo -e "\n####### Installing MySQL Workbench #######\n"
apt install mysql-workbench -y
;;
5)
#Install phpMyAdmin
echo -e "\n####### Installing phpMyAdmin #######\n"
apt install phpmyadmin -y
echo "Cofiguring apache to run phpMyAdmin"
echo "Include /etc/phpmyadmin/apache.conf" >> /etc/apache2/apache2.conf
echo "Enabling module rewrite"
a2enmod rewrite
echo "Restarting Apache Server"
service apache2 restart
;;
6)
#Install Composer
echo -e "\n####### Installing Composer #######\n"
apt install wget php-cli php-zip unzip -y
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
HASH="$(wget -q -O - https://composer.github.io/installer.sig)"
php -r "if (hash_file('SHA384', 'composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php --quiet --install-dir=/usr/local/bin --filename=composer
rm composer-setup.php
;;
7)
#Install Build Essentials
echo -e "\n####### Installing Build Essentials #######\n"
apt install -y build-essential
;;
8)
#Install Nodejs and npm
echo -e "\n####### Installing Nodejs #######\n"
curl -sL https://deb.nodesource.com/setup_10.x | sudo bash -
apt install nodejs -y
;;
9)
#Install git
echo -e "\n####### Installing Git, please configure git later... #######\n"
apt install git -y
;;
10)
#Install Ruby
echo -e "\n####### Installing Ruby #######\n"
apt install ruby-full -y
;;
11)
#Install Pip
echo -e "\n####### Installing PIP #######\n"
apt install python3-pip -y
;;
12)
#Install Vim
echo -e "\n####### Installing Vim #######\n"
apt install vim -y
;;
13)
#Install oh-my-zsh
echo -e "\n####### Installing oh-my-zsh #######\n"
apt install wget zsh -y
chsh -s $(which zsh)
sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
echo -e "\nType exit to continue..."
;;
14)
#Install yakuake
echo -e "\n####### Installing yakuake #######\n"
apt install yakuake -y
;;
15)
#Install Docker
echo -e "\n####### Installing Docker #######\n"
#Removing older versions
apt-get remove docker docker-engine docker.io
#Install the dependencies necessary to enable a new repository over HTTPS
apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common -y
#Import the repository’s GPG key using the following curl command:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
#Add the Docker APT repository to your system’s software repository list by typing:
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
#install the latest version of Docker CE (Community Edition) with:
apt-get update
apt-get install docker-ce docker-ce-cli containerd.io -y
;;
16)
#Install Docker-Compose
echo -e "\n####### Installing Docker-Compose #######\n"
#Download the Docker Compose binary into the /usr/local/bin directory with the following curl command:
curl -L "https://github.com/docker/compose/releases/download/1.23.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
#Once the download is complete, apply executable permissions to the Compose binary:
chmod +x /usr/local/bin/docker-compose
;;
17)
#Install ctop
echo -e "\n####### Installing ctop #######\n"
wget https://github.com/bcicen/ctop/releases/download/v0.7.2/ctop-0.7.2-linux-amd64 -O /usr/local/bin/ctop
chmod +x /usr/local/bin/ctop
;;
18)
#Install VirtualBox
echo -e "\n####### Installing VirtualBox #######\n"
apt-get install virtualbox -y
;;
19)
#Install Vagrant
echo -e "\n####### Installing Vagrant #######\n"
wget https://releases.hashicorp.com/vagrant/2.2.3/vagrant_2.2.3_linux_amd64.zip
unzip vagrant_2.2.3_linux_amd64.zip
mv vagrant /usr/local/bin/vagrant
chmod +x /usr/local/bin/vagrant
;;
20)
#Install Redis
echo -e "\n####### Installing Redis #######\n"
apt install redis-server -y
;;
21)
#Generating SSH keys
echo -e "\n####### Generating SSH keys #######\n"
ssh-keygen -t rsa -b 4096
;;
22)
#Bleachbit
echo -e "\n####### Installing BleachBit #######\n"
apt install bleachbit -y
;;
23)
#Peek
echo -e "\n####### Installing Peek #######\n"
add-apt-repository ppa:peek-developers/stable -y
apt update
apt install peek -y
;;
24)
#Google Chrome
echo -e "\n####### Installing Google Chrome #######\n"
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
dpkg -i google-chrome-stable_current_amd64.deb
rm google-chrome-stable_current_amd64.deb
;;
25)
#Slack
echo -e "\n####### Installing Slack #######\n"
apt install gdebi-core wget
wget -O ~/slack.deb "https://downloads.slack-edge.com/linux_releases/slack-desktop-3.3.7-amd64.deb"
gdebi --non-interactive ~/slack.deb
rm ~/slack.deb
;;
26)
#qBittorent
echo -e "\n####### Installing qBittorent #######\n"
apt install qbittorrent -y
;;
esac
done
echo -e "\n###### All Done!!! ######\n"
fi
以上是关于sh post_install.sh的主要内容,如果未能解决你的问题,请参考以下文章
如何使我的命令行在具有扩展名(.sh)和名称如“weird.sh.sh.sh”的文件上工作