Skip to content

Commit 449b822

Browse files
committed
make unattended installation
1 parent aafef86 commit 449b822

2 files changed

Lines changed: 14 additions & 13 deletions

File tree

src/inst.sh

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ inst_pacman_pkgs() {
4545
pkgs=$(grep -hvE "^\s*#|^\s*$" "$@")
4646
if [[ -n "$pkgs" ]]; then
4747
echo -e "following packages will be installed ...\n$pkgs"
48-
sudo pacman -Syu --needed $pkgs && echo "installation successfully" && return 0
48+
sudo pacman -Syu --noconfirm --needed $pkgs && echo "installation successfully" && return 0
4949
echo "installation failed"
5050
else
5151
echo "pkg files are empty; abort installation"
@@ -62,7 +62,7 @@ inst_yay_pkgs() {
6262
pkgs=$(grep -hvE "^\s*#|^\s*$" "$@")
6363
if [[ -n "$pkgs" ]]; then
6464
echo -e "following packages will be installed ...\n$pkgs"
65-
sudo pacman -Syu --needed $pkgs && echo "installation successfully" && return 0
65+
sudo pacman -Syu --noconfirm --needed $pkgs && echo "installation successfully" && return 0
6666
echo "installation failed"
6767
else
6868
echo "pkg files are empty; abort installation"
@@ -80,7 +80,7 @@ inst_flatpak_pkgs() {
8080
if [[ -n "$pkgs" ]]; then
8181
echo -e "following packages will be installed ...\n$pkgs"
8282
for pkg in "$pkgs"; do
83-
flatpak install flathub "$pkg" && echo "installation of *$pkg* successfully" && return 0
83+
flatpak install -y flathub "$pkg" && echo "installation of *$pkg* successfully" && return 0
8484
echo "installation failed"
8585
done
8686
else
@@ -93,9 +93,10 @@ inst_flatpak_pkgs() {
9393
# installation packages
9494
inst_packages() {
9595
echo "installing requirements with Pacman, Yay & Flatpak"
96-
inst_pacman_pkgs $nvidia_pkgs $pacman_pkgs
97-
inst_yay_pkgs $yay_pkgs
98-
inst_flatpak_pkgs $flatpak_pkgs
96+
inst_pacman_pkgs $nvidia_pkgs $pacman_pkgs || return 1
97+
inst_yay_pkgs $yay_pkgs || return 1
98+
inst_flatpak_pkgs $flatpak_pkgs || return 1
99+
return 0
99100
}
100101

101102
# loading kernel modules
@@ -136,6 +137,6 @@ service_setup() {
136137

137138
# installing packages
138139
inst_packages && load_modules || exit 1
139-
# services
140+
# services (no automatic aborting)
140141
psql_setup # setup postgresql
141142
service_setup # other services

src/main.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
export ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
55

66
# sudo temp for unattended install
7-
keepalive_sudo() {
7+
keep_alive_sudo() {
88
if sudo -v; then
99
{
1010
while true; do
1111
sleep 60
1212
sudo -n true
1313
done
1414
} 2>/dev/null &
15-
keepalive=$!
16-
echo "sudo keep-alive started (PID $keepalive)"
15+
keep_alive=$!
16+
echo "sudo keep-alive started"
1717
return 0
1818
else
1919
echo "sudo authentication failed"
@@ -22,13 +22,13 @@ keepalive_sudo() {
2222
}
2323

2424
# keep alive sudo permission
25-
keepalive_sudo
25+
keep_alive_sudo
2626

2727
# execute installation & recovery
2828
source "$ROOT_DIR/inst.sh" # setup package requirements
2929
source "$ROOT_DIR/borgserver.sh" # borg backup & rsync as recovery method
3030

3131
# undo keep alive sudo permission
32-
if [[ -n "$keepalive" ]] && kill -0 "$keepalive" 2>/dev/null; then
33-
kill "$keepalive"
32+
if [[ -n "$keep_alive" ]] && kill -0 "$keep_alive" 2>/dev/null; then
33+
kill "$keep_alive"
3434
fi

0 commit comments

Comments
 (0)