b8fbadb580
added wifi backport
217 lines
5.9 KiB
Bash
217 lines
5.9 KiB
Bash
!/bin/bash
|
|
NVM="$HOME/.nvm"
|
|
NVM_VERSION="v0.35.2"
|
|
NODE_VERSION="--lts"
|
|
DEV="$HOME/dev"
|
|
LIVE="$HOME/live"
|
|
STAGING="$HOME/staging"
|
|
SWAP="/swapfile"
|
|
PKG_MANAGER=$( command -v yum || command -v apt-get ) || echo "Neither yum nor apt-get found"
|
|
PKG_DEVICE=$(basename $PKG_MANAGER)
|
|
pidof systemd && SYSTEMDCALL=1 || SYSTEMDCALL=0
|
|
UPDATE=no
|
|
DATABASE=no
|
|
NGINX=no
|
|
INSTALL=no
|
|
INSTALLAMD=no
|
|
INSTALLWIFI=no
|
|
DONVM=no
|
|
|
|
RED=`tput setaf 1`
|
|
GREEN=`tput setaf 10`
|
|
YELLOW=`tput setaf 11`
|
|
PURPLE=`tput setaf 13`
|
|
RESET=`tput sgr0`
|
|
|
|
|
|
fancy_echo() {
|
|
local fmt="$1"; shift
|
|
|
|
# shellcheck disable=SC2059
|
|
printf "\n$fmt\n" "$@"
|
|
}
|
|
|
|
for i in "$@"
|
|
do
|
|
case $i in
|
|
-u|--update)
|
|
UPDATE=YES
|
|
shift # past argument=value
|
|
;;
|
|
-d|--database)
|
|
DATABASE=YES
|
|
shift # past argument=value
|
|
;;
|
|
-n|--nginx)
|
|
NGINX=YES
|
|
shift # past argument=value
|
|
;;
|
|
-i|--install|--setup)
|
|
UPDATE=YES
|
|
INSTALL=YES
|
|
DONVM=YES
|
|
# NGINX=YES
|
|
# DATABASE=YES
|
|
shift # past argument=value
|
|
;;
|
|
--install-amd)
|
|
UPDATE=YES
|
|
INSTALLAMD=YES
|
|
shift # past argument=value
|
|
;;
|
|
--install-wifi)
|
|
UPDATE=YES
|
|
INSTALLWIFI=YES
|
|
shift
|
|
;;
|
|
--default)
|
|
DEFAULT=YES
|
|
shift # past argument with no value
|
|
;;
|
|
*)
|
|
# unknown option
|
|
;;
|
|
esac
|
|
done
|
|
|
|
|
|
fancy_echo "${YELLOW}Installing PI ...${RESET}"
|
|
## Update initial packages
|
|
|
|
read -s -p "Enter Password for sudo: " sudoPW
|
|
|
|
fancy_echo "${RED}Cleaning...${RESET}"
|
|
|
|
if [ ! -d "$DEV" ]; then
|
|
mkdir -p $DEV
|
|
fi
|
|
|
|
if [ ! -d "$LIVE" ]; then
|
|
mkdir -p $LIVE
|
|
fi
|
|
|
|
if [ ! -d "$STAGING" ]; then
|
|
rm -rf $STAGING
|
|
mkdir -p $STAGING
|
|
else
|
|
mkdir -p $STAGING
|
|
fi
|
|
|
|
|
|
if [[ $UPDATE = "YES" ]]; then
|
|
fancy_echo "${PURPLE}Updating system packages${RESET}"
|
|
|
|
if [ $(basename $PKG_MANAGER) = "yum" ]; then
|
|
echo $sudoPW | sudo -S yum --assumeyes upgrade
|
|
echo $sudoPW | sudo -S yum --assumeyes install deltarpm psmisc
|
|
echo $sudoPW | sudo -S yum --assumeyes install git make automake gcc gcc-c++ kernel-devel nginx htop screen wget curl pi-bluetooth
|
|
else
|
|
echo $sudoPW | sudo -S apt-get -y -q --assume-yes update
|
|
echo $sudoPW | sudo -S apt-get -y -q --assume-yes upgrade
|
|
echo $sudoPW | sudo -S apt-get -y -q --assume-yes clean
|
|
echo $sudoPW | sudo -S apt autoremove --assume-yes
|
|
echo $sudoPW | sudo -S apt autoclean --assume-yes
|
|
fi
|
|
|
|
echo $sudoPW | sudo -S snap refresh
|
|
fi
|
|
|
|
if [[ $INSTALL = "YES" ]]; then
|
|
|
|
fancy_echo "${YELLOW}Installing Required ...${RESET}"
|
|
|
|
echo $sudoPW | sudo -S add-apt-repository ppa:nextcloud-devs/client -y
|
|
|
|
echo $sudoPW | sudo -S apt-get --assume-yes install build-essential git nginx htop screen wget curl default-jdk evolution nextcloud-client
|
|
echo $sudoPW | sudo -S apt-get -y -q --assume-yes clean
|
|
|
|
echo $sudoPW | sudo -S apt autoremove --assume-yes
|
|
echo $sudoPW | sudo -S apt autoclean --assume-yes
|
|
|
|
echo $sudoPW | sudo -S snap install chromium
|
|
echo $sudoPW | sudo -S snap install webstorm --classic
|
|
echo $sudoPW | sudo -S snap install intellij-idea-ultimate --classic
|
|
echo $sudoPW | sudo -S snap install android-studio --classic
|
|
echo $sudoPW | sudo -S snap install qownnotes
|
|
|
|
git clone https://martind2000@gitlab.silvrtree.co.uk/martind2000/usefulfiles.git $HOME/dev/usefulfiles
|
|
|
|
ln -n $HOME/dev/usefulfiles/shell_dotfiles/_bash_profile $HOME/.bash_profile
|
|
ln -n $HOME/dev/usefulfiles/shell_dotfiles/_aliases $HOME/.aliases
|
|
ln -n $HOME/dev/usefulfiles/shell_dotfiles/_bash_prompt $HOME/.bash_prompt
|
|
ln -n $HOME/dev/usefulfiles/shell_dotfiles/_gitconfig $HOME/.gitconfig
|
|
ln -n $HOME/dev/usefulfiles/shell_dotfiles/_screenrc $HOME/.screenrc
|
|
ln -n $HOME/dev/usefulfiles/shell_dotfiles/_nanorc $HOME/.nanorc
|
|
ln -n $HOME/dev/usefulfiles/shell_dotfiles/_wgetrc $HOME/.wgetrc
|
|
|
|
fi
|
|
|
|
# set up and install swap file
|
|
if [[ ! -f "$SWAP" ]]; then
|
|
fancy_echo "${YELLOW}Setting up swapfile...${RESET}"
|
|
|
|
echo $sudoPW | sudo -S fallocate -l 1G $SWAP
|
|
echo $sudoPW | sudo -S chmod 600 $SWAP
|
|
echo $sudoPW | sudo -S mkswap $SWAP
|
|
echo $sudoPW | sudo -S swapon $SWAP
|
|
|
|
add /swapfile/swapfile none swap defaults 0 0 to /etc/fstab
|
|
fi
|
|
|
|
# setup node and npm
|
|
if [[ $DONVM = "YES" ]]; then
|
|
fancy_echo "${YELLOW}Installing Node...${RESET}"
|
|
|
|
# Will enter here if $DIRECTORY exists, even if it contains spaces
|
|
|
|
curl -o- https://raw.githubusercontent.com/creationix/nvm/$NVM_VERSION/install.sh | bash
|
|
export NVM_DIR=$NVM
|
|
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
|
|
|
|
source $HOME/.bashrc
|
|
source $NVM/nvm.sh
|
|
nvm install $NODE_VERSION
|
|
fi
|
|
|
|
if [[ $INSTALL = "YES" ]]; then
|
|
fancy_echo "${YELLOW}Installing Node Global Packages...${RESET}"
|
|
npm install -g gulp pm2@latest npm-check npm-install-missing
|
|
pm2 update
|
|
fi
|
|
|
|
|
|
if [[ $INSTALLAMD = "YES" ]]; then
|
|
|
|
fancy_echo "${YELLOW}Installing AMD...${RESET}"
|
|
# from https://askubuntu.com/questions/1066105/how-to-install-amd-graphic-drivers-on-ubuntu-18-04
|
|
|
|
# Ensures NVIDIA is removed
|
|
echo $sudoPW | sudo -S apt-add-repository -r ppa:graphics-drivers/ppa --yes && \
|
|
sudo -S apt update --assume-yes && \
|
|
sudo -S apt upgrade --assume-yes && \
|
|
sudo -S apt autoremove --assume-yes && \
|
|
sudo -S apt autoclean --assume-yes
|
|
|
|
# install amd non propritery
|
|
echo $sudoPW | sudo -S add-apt-repository ppa:oibaf/graphics-drivers --yes --enable-source
|
|
echo $sudoPW | sudo -S apt-get update --assume-yes
|
|
echo $sudoPW | sudo -S apt upgrade --assume-yes
|
|
|
|
echo $sudoPW | sudo -S dpkg --configure -a
|
|
echo $sudoPW | sudo -S dpkg-reconfigure lightdm
|
|
|
|
|
|
echo $sudoPW | sudo -S apt-get install mesa-vdpau-drivers
|
|
|
|
fi
|
|
|
|
if [[ $INSTALLWIFI = "YES"]]; then
|
|
fancy_echo "${YELLOW}Installing iwlwifi...${RESET}"
|
|
# from https://askubuntu.com/questions/1066105/how-to-install-amd-graphic-drivers-on-ubuntu-18-04
|
|
|
|
echo $sudoPW | sudo -S add-apt-repository ppa:canonical-hwe-team/backport-iwlwifi
|
|
echo $sudoPW | sudo -S apt-get update
|
|
|
|
echo $sudoPW | sudo -S sudo apt install backport-iwlwifi-dkms
|
|
|
|
fi |