在 Ubuntu 上自动化安装基本应用的方法, 安装及使用Alfred, Ubuntu Post Installation Script, post_install.sh

 

默认安装的 Ubuntu 并未预先安装所有必需的应用。你可能需要在网上花几个小时或者向其他 Linux 用户寻求帮助才能找到并安装 Ubuntu 所需的应用。如果你是新手,那么你肯定需要花更多的时间来学习如何从命令行(使用 apt-get 或 dpkg)或从 Ubuntu 软件中心搜索和安装应用。一些用户,特别是新手,可能希望轻松快速地安装他们喜欢的每个应用。如果你是其中之一,不用担心。在本指南中,我们将了解如何使用名为 “Alfred” 的简单命令行程序在 Ubuntu 上安装基本应用。

Alfred 是用 Python 语言编写的自由、开源脚本。它使用 Zenity 创建了一个简单的图形界面,用户只需点击几下鼠标即可轻松选择和安装他们选择的应用。你不必花费数小时来搜索所有必要的应用程序、PPA、deb、AppImage、snap 或 flatpak。Alfred 将所有常见的应用、工具和小程序集中在一起,并自动安装所选的应用。如果你是最近从 Windows 迁移到 Ubuntu Linux 的新手,Alfred 会帮助你在新安装的 Ubuntu 系统上进行无人值守的软件安装,而无需太多用户干预。请注意,还有一个名称相似的 Mac OS 应用,但两者有不同的用途。

 

在 Ubuntu 上安装 Alfred

Alfred 安装很简单!只需下载脚本并启动它。就这么简单。

$ wget https://raw.githubusercontent.com/derkomai/alfred/master/alfred.py
$ python3 alfred.py

或者,使用 wget 下载脚本,如上所示,只需将 alfred.py 移动到 $PATH 中:

$ sudo cp alfred.py /usr/local/bin/alfred

使其可执行:

$ sudo chmod +x /usr/local/bin/alfred

并使用命令启动它:

$ alfred

 

使用 Alfred 脚本轻松快速地在 Ubuntu 上安装基本应用程序

按照上面所说启动 Alfred 脚本。这就是 Alfred 默认界面的样子。

在 Ubuntu 上自动化安装基本应用的方法, 安装及使用Alfred
在 Ubuntu 上自动化安装基本应用的方法, 安装及使用Alfred

如你所见,Alfred 列出了许多最常用的应用类型,例如:

  • 网络浏览器,
  • 邮件客户端,
  • 消息,
  • 云存储客户端,
  • 硬件驱动程序,
  • 编解码器,
  • 开发者工具,
  • Android,
  • 文本编辑器,
  • Git,
  • 内核更新工具,
  • 音频/视频播放器,
  • 截图工具,
  • 录屏工具,
  • 视频编码器,
  • 流媒体应用,
  • 3D 建模和动画工具,
  • 图像查看器和编辑器,
  • CAD 软件,
  • PDF 工具,
  • 游戏模拟器,
  • 磁盘管理工具,
  • 加密工具,
  • 密码管理器,
  • 存档工具,
  • FTP 软件,
  • 系统资源监视器,
  • 应用启动器等。

你可以选择任何一个或多个应用并立即安装它们。在这里,我将安装 “Developer bundle”,因此我选择它并单击 OK 按钮。

在 Ubuntu 上自动化安装基本应用的方法, 安装及使用Alfred
在 Ubuntu 上自动化安装基本应用的方法, 安装及使用Alfred

现在,Alfred 脚本将自动你的 Ubuntu 系统上添加必要仓库、PPA 并开始安装所选的应用。

在 Ubuntu 上自动化安装基本应用的方法, 安装及使用Alfred
在 Ubuntu 上自动化安装基本应用的方法, 安装及使用Alfred

安装完成后,你将看到以下消息。

在 Ubuntu 上自动化安装基本应用的方法, 安装及使用Alfred
在 Ubuntu 上自动化安装基本应用的方法, 安装及使用Alfred

恭喜你!已安装选定的软件包。

你可以使用以下命令在 Ubuntu 上查看最近安装的应用

$ grep " install " /var/log/dpkg.log

你可能需要重启系统才能使用某些已安装的应用。类似地,你可以方便地安装列表中的任何程序。

提示一下,还有一个由不同的开发人员编写的类似脚本,名为 post_install.sh。它与 Alfred 完全相同,但提供了一些不同的应用。请查看以下链接获取更多详细信息。

 

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=$("${cmd[@]}" "${options[@]}" 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

或者直接下载:

$ wget -d -c -O post_install.sh https://gist.githubusercontent.com/waleedahmad/a5b17e73c7daebdd048f823c68d1f57a/raw/4c334a4b52b848df9501ad394ad07ddb1648fe2a/post_install.sh

$ chmod +x post_install.sh

$ sudo ./post_install.sh
在 Ubuntu 上自动化安装基本应用的方法, 安装及使用Alfred
在 Ubuntu 上自动化安装基本应用的方法, 安装及使用Alfred

上面的命令是自动安装以下文件:

  1. Sublime Text 3,
  2. LAMP Stack,
  3. Build Essentials,
  4. Node.js,
  5. Git,
  6. Composer,
  7. JDK 8,
  8. Bleachbit,
  9. Ubuntu Restricted Extras,
  10. VLC Media Player,
  11. Unity Tweak Tool,
  12. Google Chrome,
  13. Teamiewer,
  14. Skype,
  15. Paper GTK Theme,
  16. Arch Theme,
  17. Arc Icons,
  18. Numix Icons,
  19. Multiload Indicator,
  20. Pensor,
  21. Netspeed Indicator,
  22. Generate SSH Keys,
  23. Ruby,
  24. Sass,
  25. Vnstat,
  26. Webpack,
  27. Grunt,
  28. Gulp.
在 Ubuntu 上自动化安装基本应用的方法, 安装及使用Alfred
在 Ubuntu 上自动化安装基本应用的方法, 安装及使用Alfred

这两个脚本能让懒惰的用户,特别是新手,只需点击几下鼠标就能够轻松快速地安装他们想要在 Ubuntu Linux 中使用的大多数常见应用、工具、更新、小程序,而无需依赖官方或者非官方文档的帮助。

 

项目地址:https://gist.github.com/waleedahmad/a5b17e73c7daebdd048f823c68d1f57a

 

本文:在 Ubuntu 上自动化安装基本应用的方法, 安装及使用Alfred, Ubuntu Post Installation Script, post_install.sh

Loading

Add a Comment

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.