-
Notifications
You must be signed in to change notification settings - Fork 18
/
packages.sh
executable file
·135 lines (99 loc) · 3.75 KB
/
packages.sh
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
#!/bin/bash
#set -x
# pi-ap: These scripts configure a Raspberry Pi into a wireless Access Point
# Source: https://github.com/f1linux/pi-ap
# Version: 01.10.02
# License: GPL 3.0
# Script Author: Terrence Houlahan Linux & Network Engineer
# Contact: [email protected]
# Linkedin: www.linkedin.com/in/terrencehoulahan
# Do not edit below sources
source "${BASH_SOURCE%/*}/variables.sh"
source "${BASH_SOURCE%/*}/functions.sh"
echo
echo "$(tput setaf 5)****** PACKAGES: Remove conflicting packages or bloatware from default Raspbian image ******$(tput sgr 0)"
echo
# usbmount: interferes with SystemD auto-mounts which we will use for the USB Flash Drive where video and images are written locally to
# libreoffice: it is just crap and not required on a device being used as a video camera
echo
echo "Removing packages listed in packages-list-purge.txt"
echo
readarray arrayPackagesListPURGE < $PATHSCRIPTS/packages-list-purge.txt
for i in ${arrayPackagesListPURGE[@]}; do
if [[ ! $(dpkg -l | grep "^ii $i[[:space:]]") = '' ]]; then
apt-get -y purge $i
echo "Removed package $i"
else
echo "Package $i not present on system"
fi
done
echo
echo "$(tput setaf 5)****** PACKAGES: Re-Sync Index: ******$(tput sgr 0)"
echo
until apt-get -y update
do
echo
echo "$(tput setaf 5)apt-get update failed. Retrying$(tput sgr 0)"
echo
echo "$(tput setaf 3)If TOTAL failure check Internet connection$(tput sgr 0)"
echo
echo "$(tput setaf 3)If PARTIAL Failure with Error:$(tput sgr 0)"
echo
echo "$(tput setaf 1) E: Release file for <Repo URL> is not valid yet (invalid for another <time>). Updates for repository will not be applied$(tput sgr 0)"
echo
echo "$(tput setaf 3)Check Host Time is correct by executing: timedatectl$(tput sgr 0)"
echo
done
echo 'Package Index Updated'
echo
echo
echo "$(tput setaf 5)****** Install Packages: ******$(tput sgr 0)"
echo
# For info about a particular package in the list of packages to be installed in packages-list-install.txt:
# sudo apt-cache show packagename
# Package debconf-utils must be installed separately and FIRST before mass package installation occurs:
# If a subsequent package tries to open a dialog requiring user input and debconf-utils has not been installed
# it will break unattended installation by pausing script for user input. Very bad.
if [[ $(dpkg -l | grep "^ii debconf-utils[[:space:]]") = '' ]]; then
until apt-get -y install debconf-utils
do
echo
echo "Package $(tput setaf 3)$i $(tput sgr 0)not found"
echo
echo "Skipping to next package in packages-list-install.txt"
echo
break
done
elif [[ $(dpkg -l | grep "^ii debconf-utils[[:space:]]") = $(dpkg -l | grep "^ii debconf-utils[[:space:]]") ]]; then
echo "Package debconf-utils already installed"
fi
export DEBIAN_FRONTEND=noninteractive
readarray arrayPackagesListInstall < $PATHSCRIPTS/packages-list-install.txt
for i in ${arrayPackagesListInstall[@]}; do
if [[ $(dpkg -l | grep "^ii $i[[:space:]]") = '' ]]; then
until apt-get -y install $i
do
echo
echo "Package $(tput setaf 3)$i $(tput sgr 0)not found"
echo
echo "Skipping to next package in packages-list-install.txt"
echo
break
done
elif [[ $(dpkg -l | grep "^ii $i[[:space:]]") = $(dpkg -l | grep "^ii $i[[:space:]]") ]]; then
echo "Package $i already installed"
fi
done
echo
echo "Updating the $(tput setaf 3)apt-file$(tput sgr 0) DB:"
echo
# Update apt-file DB with new packages installed so they can be searched with this utility:
$(command -v apt-file) update
echo "Updating the $(tput setaf 6)locate$(tput sgr 0) DB"
# Populate the *locate* DB:
$(command -v updatedb)
echo
echo
echo "$(tput setaf 5)****** Set Default Package Preferences: ******$(tput sgr 0)"
echo
update-alternatives --set editor /usr/bin/vim.basic