sh安装后脚本ubuntu1604shell(代码片段)

author author     2022-12-18     571

关键词:

#!/usr/bin/env sh

CAN_I_RUN_SUDO=$(sudo -n uptime 2>&1|grep "load"|wc -l)
if [ $CAN_I_RUN_SUDO -ne 0 ]; then
    echo "Installing sudo"
    apt-get install -y sudo
fi

# function to get distro and version used by vim install
get_distribution_version() 
	lsb_dist=""
	# Every system that we officially support has /etc/os-release
	if [ -r /etc/os-release ]; then
		lsb_dist_vers="$(. /etc/os-release && echo "$ID $VERSION_ID")"
	fi
	# Returning an empty string here should be alright since the
	# case statements don't act unless you provide an actual value
	echo "$lsb_dist_vers"


get_docker_compose_latest_release() 
  DOCKER_COMPOSE="docker/compose"
  curl --silent "https://api.github.com/repos/$DOCKER_COMPOSE/releases/latest" | # Get latest release from GitHub api
    grep '"tag_name":' |                                            # Get tag line
    sed -E 's/.*"([^"]+)".*/\1/'                                    # Pluck JSON value



lsb_dist_vers=$( get_distribution_version )
distro=$(echo $lsb_dist_vers | awk ' print $1 ' | tr '[:upper:]' '[:lower:]')
version=$(echo $lsb_dist_vers | awk ' print $2 ' | tr '[:upper:]' '[:lower:]')

case "$distro" in

	ubuntu)
	  if [ $version = "16.04" ] || [ $version = "14.04" ]; then
			sudo add-apt-repository -y ppa:jonathonf/vim
			sudo apt-get update
			sudo apt-get install -y vim
		fi
	;;

	debian)
		if [ $version = "9" ]; then
			sudo apt-get install -y software-properties-common dirmngr --install-recommends
			sudo add-apt-repository 'deb http://ppa.launchpad.net/jonathonf/vim/ubuntu xenial main'
			sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 8CF63AD3F06FC659
			sudo apt-get update
			sudo apt-get install -y vim
		fi
	;;

	*)
		echo 'sorry, the script is  currently support ubuntu1604 and debian9 only'
	;;

esac

#fix error on some debian version when updating(debian 9.4 scaleway)
sed -i 's/^deb[[:space:]]\1,\http:\/\/ftp.debian.org\/debian[[:space:]]\1,\stretch\/updates[[:space:]]\1,\main/#&/g' /etc/apt/sources.list
sed -i 's/^deb-src[[:space:]]\1,\http:\/\/ftp.debian.org\/debian[[:space:]]\1,\stretch\/updates[[:space:]]\1,\main/#&/g' /etc/apt/sources.list



#change localtime to localtime
sudo rm /etc/localtime
sudo ln -s /usr/share/zoneinfo/Africa/Tunis /etc/localtime


echo "check if curl is installed and installed it if not"
curl --version > /dev/null 2>&1
CURL_IS_INSTALLED=$?
if [ $CURL_IS_INSTALLED -ne 0 ]; then
    echo "Installing curl"
    sudo apt-get install -y curl
else
    echo "curl is already installed"
fi

echo "Install git and tmux"
sudo apt-get install -y git tmux

git config --global user.email "you@example.com"
git config --global user.name "Your Name"


echo "installing zsh"
#echo "installing zsh 5.5.1"
#curl -fLo libtinfo6_6.1+20180210-4_amd64.deb http://ftp.br.debian.org/debian/pool/main/n/ncurses/libtinfo6_6.1+20180210-4_amd64.deb 
#curl -fLo zsh-common_5.5.1-1_all.deb http://ftp.br.debian.org/debian/pool/main/z/zsh/zsh-common_5.5.1-1_all.deb
#curl -fLo zsh_5.5.1-1+b1_amd64.deb http://ftp.br.debian.org/debian/pool/main/z/zsh/zsh_5.5.1-1+b1_amd64.deb
#sudo dpkg -i libtinfo6_6.1+20180210-4_amd64.deb
#sudo dpkg -i zsh-common_5.5.1-1_all.deb
#sudo dpkg -i zsh_5.5.1-1+b1_amd64.deb
#rm -f libtinfo6_6.1+20180210-4_amd64.deb zsh-common_5.5.1-1_all.deb zsh_5.5.1-1+b1_amd64.deb
sudo apt-get install -y zsh

echo "tmux config"
USER=`whoami`
USER_HOME="$(echo -n $(bash -c "cd ~$USER && pwd"))"
echo "set-option -g default-shell /bin/zsh"$'\n'"set -g status off" >> "$USER_HOME"/.tmux.conf



# Get prezto
    git clone --recursive https://github.com/sorin-ionescu/prezto.git ~/.zprezto

    # Backup zsh config if it exists
    if [ -f ~/.zshrc ];
       then
           mv ~/.zshrc ~/.zshrc.backup
    fi

    # Create links to zsh config files
    ln -s ~/.zprezto/runcoms/zlogin ~/.zlogin
    ln -s ~/.zprezto/runcoms/zlogout ~/.zlogout
    ln -s ~/.zprezto/runcoms/zpreztorc ~/.zpreztorc
    ln -s ~/.zprezto/runcoms/zprofile ~/.zprofile
    ln -s ~/.zprezto/runcoms/zshenv ~/.zshenv
    ln -s ~/.zprezto/runcoms/zshrc ~/.zshrc
    curl https://gist.githubusercontent.com/souhaiebtar/738c13454c547bc22629fcb80fed747f/raw/1664b93216f78fad2289aa75549ac8d16cde44cc/zpreztorc > ~/.zprezto/runcoms/zpreztorc
    
    curl -fLo ~/.zprezto/modules/completion/external/src/_docker \
https://raw.github.com/felixr/docker-zsh-completion/master/_docker

    sudo sed -i "/$USER/s/bash/zsh/g" /etc/passwd


docker --version > /dev/null 2>&1
DOCKER_IS_INSTALLED=$?

if [ $DOCKER_IS_INSTALLED -gt 0 ]; then
           echo "Install docker and adding it to the docker group"
            sudo apt-get -f install
            sudo curl https://get.docker.com/ | bash
            username=`whoami`
            sudo usermod -aG docker $username
   fi

echo "copying docker compose and adding execute permission to it"
sudo curl -L https://github.com/docker/compose/releases/download/$(get_docker_compose_latest_release)/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
#fix things
sudo apt-get -f install

echo "installing vim-plug and plugin"
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
    https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

curl -L https://gist.githubusercontent.com/souhaiebtar/d6d246b3e038abf26e72be5f113ace75/raw/d2c7868bdf73e71649710464af26c90eb5217acc/.vimrc > ~/.vimrc

rm -f ~/.zshrc

curl -L https://gist.githubusercontent.com/souhaiebtar/9ad3f5f9387b72ac1f005567bde6c91e/raw/ed53b1b742ed8235f2ac4524207809145d2fbcdf/.zshrc > ~/.zshrc

sudo apt-get install -y ufw
sudo ufw allow ssh


# read -p "add port needed by docker swarm? (y/n) " RESP
# if [ "$RESP" = "y" ]; then
#     echo "adding port needed by docker swarm"
#     sudo ufw allow 2376/tcp && sudo ufw allow 7946/udp
#     sudo ufw allow 7946/tcp && sudo ufw allow 80/tcp 
#     sudo ufw allow 2377/tcp && sudo ufw allow 4789/udp
# else
#     echo "OKAY"
# fi

sudo ufw reload

sudo ufw --force enable

echo "vim +PlugInstall"
vim +PlugInstall +qall

#echo "zsh"
#zsh

#echo "for a docker swarm manager"
#echo "ufw allow 2376/tcp"
#echo "ufw allow 2377/tcp"
#echo "ufw allow 7946/tcp"
#echo "ufw allow 7946/udp"
#echo "ufw allow 4789/udp"

#echo "for a docker swarm worker"
#echo "ufw allow 2376/tcp"
#echo "ufw allow 7946/tcp" 
#echo "ufw allow 7946/udp" 
#echo "ufw allow 4789/udp"

sh用于在ubuntu16系统上设置laravelproduction环境的shell脚本。(代码片段)

查看详情

sh简单的脚本shell自动安装nodejs+buildwebserverjs(代码片段)

查看详情

sh1604安装程序gnomev1(代码片段)

查看详情

sh安装后的ubuntu(代码片段)

查看详情

sh适用于linuxdebian/ubuntu的drupal安装脚本(代码片段)

查看详情

sh脚本在ubuntu上安装git和ansible(代码片段)

查看详情

sh简化ubuntu中telegram安装的小脚本。(代码片段)

查看详情

sh在ubuntu安装所有必需的软件安装后。(代码片段)

查看详情

sh用于ubuntu14.0.4的lemp堆栈安装bash脚本(代码片段)

查看详情

sh用于ubuntu14.0.4的lemp堆栈安装bash脚本(代码片段)

查看详情

shell脚本内调用另外一个shell脚本的几种方法(代码片段)

   有时会在一个shell脚本(如test_call_other_shell.sh)中调用另外一个shell脚本(如parameter_usage.sh),这里总结几种可行的方法,这些方法在linux上和windows上(通过GitBash)均适用:   1.通过source:运行在相同的进程,在test_cal... 查看详情

sh我用于ibm的分布式minio集群的安装后脚本(代码片段)

查看详情

安装脚本的 shell 脚本与 perl - perl 有多普遍?

】安装脚本的shell脚本与perl-perl有多普遍?【英文标题】:shellscriptvs.perlforaninstallscript-howubiquitousisperl?【发布时间】:2011-04-1305:16:42【问题描述】:我想以npm(curlhttp://example.com/install.sh|sh)的方式创建一个安装脚本,但这让我问了... 查看详情

sh用于从ubuntu构建安全的mysql服务器的shell脚本。(必须以root身份运行并准备使用大量密码)(代码片段)

查看详情

ubuntu中写一个shell脚本的过程

gedithello.sh,然后输入#!/bin/bashecho"Helloworld!"chmod+xhello.sh./hello.sh 查看详情

sh在ubuntu上安装和设置no-ip动态ip更新程序引擎的脚本(代码片段)

查看详情

shell脚本中export命令未生效,原因详解(代码片段)

1.问题发现 安装 jemalloc后,执行 /usr/bin/jemalloc.sh脚本生效环境变量 LD_PRELOAD。执行过后发现环境变量并未生效。过程如下:[root@10-27-30-48shao]#morejemalloc.sh#!/bin/shprefix=/usrexec_prefix=/usrlibdir=/usr/l 查看详情

shell脚本中export命令未生效,原因详解(代码片段)

1.问题发现 安装 jemalloc后,执行 /usr/bin/jemalloc.sh脚本生效环境变量 LD_PRELOAD。执行过后发现环境变量并未生效。过程如下:[root@10-27-30-48shao]#morejemalloc.sh#!/bin/shprefix=/usrexec_prefix=/usrlibdir=/usr/l 查看详情