This repository has been archived by the owner on Mar 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
new-computer.bash
141 lines (122 loc) · 3.51 KB
/
new-computer.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/bin/bash
# ------------------------------------------------------------------------------
# | Functions # http://stackoverflow.com/a/6347145
# ------------------------------------------------------------------------------
# Checks if a package is installed. If it is not, the function installs it.
installifnotinstalled() {
command -v $1 >/dev/null 2>&1 || {
echo "$1 is not installed. Installing $1..." >&2;
sudo apt install -y "$1";
}
}
# ------------------------------------------------------------------------------
# Check if this script is running on a Linux system.
if ! [ "$OSTYPE" = "linux-gnu" ]; then
echo "You are not using a Linux computer. Run this script on a Linux system with Ubuntu or Lubuntu installed."
exit
else
# OK, the script is running on Linux.
# Now check if we have 'gawk'.
command -v gawk >/dev/null 2>&1 || { echo "Please enter your password so that I can install gawk..." >&2; sudo apt install -y gawk; }
# Now that we have 'gawk', we can check if this flavour of Linux is Ubuntu.
OPERATINGSYSTEM=$(gawk -F= '/^NAME/{print $2}' /etc/os-release)
if [ ! "$OPERATINGSYSTEM" = "\"Ubuntu\"" ]; then
echo "This script is meant to be run on an Ubuntu based system with \"apt\" available."
echo "Exiting..."
exit
fi
fi
# OK, looks like we have the enviroment we are expecting.. Proceed.
# Update current packages?
read -p "Before installing some new software packages, do you want to update your existing system? (Y/n?) " choice
case "$choice" in
y|Y ) echo; echo "Sure, why not eh?!"; sudo apt update -y; sudo apt upgrade -y; sudo apt autoremove -y;;
n|N ) echo; echo "OK."; echo;;
* ) echo "Invalid response. Choose Y or N next time, bro."; echo "Exiting..."; exit;;
esac
# Install all the softwares.
echo "-------Setup a lot of software...-------"
PACKAGES=(
apache2
curl
git
ffmpeg
imagemagick
mysql-server
mysql-client
nodejs
php
libapache2-mod-php
php-cli
php-curl
php-ldap
php-openssl
php-mbstring
php-mcrypt
php-mysql
php-xml
python3-pip
ruby
rubygems
sqlite3
wget
xclip
unzip
gifsicle
youtube-dl
)
for i in "${PACKAGES[@]}"
do
installifnotinstalled "$i"
done
# On Ubuntu, 'node' is not 'node' until it's linked to 'nodejs' ¯\_(ツ)_/¯
# https://github.com/nodejs/node-v0.x-archive/issues/3911#issuecomment-8956154
sudo ln -s /usr/bin/nodejs /usr/bin/node
echo
# Enable SSL w/ Apache
sudo a2enmod ssl
# Install AWS CLI
echo "-------Setup AWS and B2 CLI-------"
pip install --upgrade pip
pip install awscli --upgrade --user
sudo apt install awscli
# Install Backblaze just because..
sudo pip install --upgrade --ignore-installed b2
# Install Composer
echo "-------Setup Composer-------"
cd ~
curl -sS https://getcomposer.org/installer -o composer-setup.php
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
composer --version
# Install global NPM packages
echo "-------Setup NPM-------"
NPMPACKAGES=(
cloudinary-cli
create-react-app
gatsby-cli
gatsby
sass
surge
)
# https://stackoverflow.com/a/41395398/1171790
mkdir ~/.npm-global
export NPM_CONFIG_PREFIX=~/.npm-global
export PATH=$PATH:~/.npm-global/bin
npm i -g npm
for i in "${NPMPACKAGES[@]}"
do
npm i -g "$i"
done
# Setup Git.
echo "-------Setup Git-------"
cd ~/.dotfiles
chmod +x ./git/git-config.bash
./git/git-config.bash
echo
echo "All done. Your softwares are installed! :)"
echo
echo "Your NodeJS version is: $(node -v)"
echo "Your npm version is: $(npm -v)"
echo "`git config --list` will display your Git configuration."
echo
exit