-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprofile-enabler.sh
More file actions
executable file
·105 lines (85 loc) · 2.29 KB
/
profile-enabler.sh
File metadata and controls
executable file
·105 lines (85 loc) · 2.29 KB
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
#!/bin/bash
scriptDirRoot="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
cd "$scriptDirRoot"
git pull
. ./functions/basicFunctions.sh
. ./functions/packageFunctions.sh
. ./functions/networkingFunctions.sh
. ./functions/astroFunctions.sh
. ./functions/restrictedPackagesFunctions.sh
. ./functions/devEnvFunctions.sh
. ./functions/dockerFunctions.sh
# --------------------------------------------
# Script to install / enable a profile
# --------------------------------------------
# Define some constants
RED='\033[0;31m'
GREEN='\033[1;32m'
PURPLE='\033[1;35m'
NC='\033[0m' # No Color
export MAKEFLAGS="-j $(nproc)"
scriptDir="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
profilesFolder="$scriptDir/profiles/"
# Welcome message
echo
echo "--------------------------------------------"
echo " Tino's Profile enabler"
echo "--------------------------------------------"
echo
if [ -z "$1" ]; then
# List available profiles
echo "Available profiles: "
echo
i=1
for d in $profilesFolder*; do
echo " $i) $(basename $d)"
profiles+=("$d")
i=$((i + 1))
done
echo
printf "Enter number: "
# Let user select a profile
read selectedProfile
echo
re='^[0-9]+$'
if ! [[ $selectedProfile =~ $re ]]; then
echo -n "$RED"
echo "error: Not a number$NC" >&2
exit -1
fi
# Run profile specific profile installer if it exists
echo
profileName=${profiles[$selectedProfile - 1]}
else
profileName=$scriptDir/profiles/$1
fi
echo "ProfileName: ${profileName}"
distro=$(head -n 1 ${profileName}/distro)
echo "Distribution: ${distro}"
# Copy defaults
echo
echo "Copying default files...."
rm -rf ~/wallpapers
cp -ra ${scriptDir}/defaults/. ~/
# Copy profile files
echo
echo "Copying profile files..."
mkdir -p ~/.scripts
rm ~/.profile
cp -ra ${profileName}/. ~/.scripts/
ln -s ~/.zprofile ~/.profile
# Run default profile-installer
echo
. ./default-profile-install-${distro}.sh
ProfileInstallScriptPath=${profileName}/profile-enabler.sh
if [ -f "$ProfileInstallScriptPath" ]; then
. $ProfileInstallScriptPath
fi
profileDirName=$(basename $profileName)
echo "$profileDirName"
echo "#!/bin/bash" >~/.scripts/updateDotFiles
echo "bash $scriptDirRoot/profile-enabler.sh $profileDirName" >>~/.scripts/updateDotFiles
chmod +x ~/.scripts/updateDotFiles
rm -rf ~/.files
echo
echo "DONE!"