aboutsummaryrefslogtreecommitdiff
path: root/new-machine-setup.sh
blob: d1ea48852a434cd1ee39594830151694e765d80b (plain) (blame)
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
#!/usr/local/bin/bash
#
# FILE  : dotfiles.sys/new-machine.setup.sh
# TARGET: none
# AUTHOR: tgwil
#
# This script sets up a new machine.
# It includes only things necessary for EVERY machine.
#
# This installer assumes that:
# - this repository is cloned to /usr/local/share/dotfiles.sys
# - /usr/local/share/dotfiles.sys/ is owned by root
# - the installer is being run by a user with sudo privileges


########################################################################
## Setup
########################################################################
# Set script output colors
GREEN="\e[32m"
YELLOW="\e[33m"
WARN="\e[1;31m"
ENDCOLOR="\e[0m"


# Check if running as root
if [[ "${EUID}" -ne 0 ]]; then
    echo -e "${WARN}WARNING: This script requires root privileges${ENDCOLOR}"
    echo -e "INFO   : Abort!"
    exit 1
else
    # Startup message
    echo "### Starting dotfiles.sys installation... ###"
fi


# Give user the chance to abort before shit starts happening.
echo -e "${WARN}WARNING: This installer is meant for new machines. It will replace system-level configuration files. [A]bort, [C]ontinue: ${ENDCOLOR}"
echo -en "\033[1A\033[1000C"
read -n1 confirm
confirm_invalid_selection=0
while
    case $confirm in
        "a"|"A")
            echo "INFO   : Abort!"
            exit 0;;
        "c"|"C")
            break;;
        *)
            echo -e "${WARN}ERROR  : Invalid selection, try again...${ENDCOLOR}"
            confirm_invalid_selection=1;;
    esac
    [[ $confirm_invalid_selection==1 ]]
do true; done


########################################################################
## Install Packages
########################################################################
echo "INFO   : Proceed with package installation? [y/n]: "
echo -en "\033[1A\033[1000C"
read -n1 do_package_install
package_invalid_selection=0
while
    case $do_package_install in
        "y"|"Y")
            pkg update
            pkg upgrade && sudo pkg install \
                                devel/autotools \
                                devel/cmake \
                                devel/git \
                                devel/libvterm \
                                devel/pkgconf \
                                devel/roswell \
                                editors/emacs \
                                editors/nano \
                                ports-mgmt/portconfig \
                                security/gnupg \
                                security/sudo \
                                shells/bash \
                                shells/bash-completion \
                                sysutils/coreutils \
                                sysutils/dmidecode \
                                sysutils/exa \
                                sysutils/gdisk
            echo "INFO   : Packages installed and updated."
            break;;
        "n"|"N")
            echo "INFO   : Skipping package installation and updates."
            break;;
        *)
            echo -e "${WARN}ERROR  : Invalid selection, try again...${ENDCOLOR}"
            package_invalid_selection=1;;
    esac
    [[ $package_invalid_selection==1 ]]
do true; done