-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Hyde-install
138 lines (119 loc) · 4.4 KB
/
Hyde-install
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
#!/bin/env bash
export CLI_PATH=$(dirname $(dirname ${0}))
export libDir=${CLI_PATH}/lib/hyde-cli
export PATH="$libDir:$PATH"
fresh=false
export is_fresh_install=true
. GLOBAL-hyde
. FUNCTIONS-hyde
#? One time set up on terminal
install_distro() {
if [ "${1}" = "--fresh" ]; then export fresh=true; fi
# . /etc/os-release
PACKAGE_MANAGER=$(which pacman >/dev/null 2>&1 && echo "pacman" || true)
# PACKAGE_MANAGER=${PACKAGE_MANAGER:-$(which apt >/dev/null 2>&1 && echo "apt" || true)}
# PACKAGE_MANAGER=${PACKAGE_MANAGER:-$(which zypper >/dev/null 2>&1 && echo "zypper" || true)}
# PACKAGE_MANAGER=${PACKAGE_MANAGER:-$(which yum >/dev/null 2>&1 && echo "yum" || true)}
echo "Package manager: $PACKAGE_MANAGER"
case "${PACKAGE_MANAGER}" in
"dnf")
Install_Hyde-DNF "${newCloneDir}" "${GIT}"
;;
"pacman")
Install-Hyde-pacman "${newCloneDir}" "${GIT}"
;;
*)
print_prompt -r "Can't recognize your package manager: '${PACKAGE_MANAGER}' "
# Install-Hyde-pacman "${newCloneDir}" "${GIT}"
# Add the commands for other distributions here
echo ""
;;
esac
}
try_relogin() {
if pkg_installed sddm && grep "Active: inactive (dead)" <<<"$(systemctl status sddm.service)"; then
print_prompt -y "It is advised to relogin on after installation.."
ask_confirm "Yy" || exit 0
print_prompt -y "Restarting to make Hyde Work"
systemctl restart sddm
fi
}
handle_install() {
if cd "${newCloneDir}"/Scripts; then
print_prompt -m "[*] " -y "Using existing directory"
if [[ ${is_link} == true ]]; then
echo -e "Hyde-cli will make ${newCloneDir} your clone directory By restoring the links"
# set_branch
check_integrity
print_prompt -y "Successfully migrated the clone directory: ${newCloneDir}"
else
install_distro
fi
else
install_distro --fresh
fi
}
main() {
if ! handle_install; then return 1; fi
set_metadata "${newCloneDir}" && try_relogin
"${CLI_PATH}/bin/Hyde" reload
}
# Variables
export install_packages_list="${HYDE_RUNTIME_DIR}/temporary-apps"
export barLine="$(printf '=%.0s' $(seq 1 "$(tput cols)"))"
export cacheDir="${HOME}/.cache/hyde"
export META_FILE="${cacheDir}/hyde.meta"
is_link=false
while (("$#")); do
case "$1" in
-d | --dir)
newCloneDir="$2"
shift 2
;;
-l | --link)
is_link=true
shift 1
;;
-g | --git)
GIT="$2"
shift 2
;;
--no-package)
export no_package=true
shift 1
;;
--branch-opt)
export branch_opt=true
shift 1
;;
*)
cat <<HANDLE_ERROR
Unknown option: $1
Please run: 'Hyde-install' Install Hyde (Defaults)
Advanced usage: [Hyde-install] --[options]
-d|--dir /path/to/Clone/Hyde Clone Hyde in a Custom path then run installation
Default: '${HOME}/.cache/hyde/Hyde'
-g|--git https://gitclone/repo/link/ Remote Repository link to be cloned
Default: 'https://github.com/prasanthrangan/hyprdots'
-l|--link Transfer the link to a Clone Directory
Default: 'false'
Flags:
--branch-opt Ask to what branch to install
--no-package Skip the package installation
HANDLE_ERROR
exit 1
;;
esac
done
[[ -n ${newCloneDir} ]] && print_prompt -y "Custom clone directory: ${newCloneDir}"
[[ ${is_link} == true ]] && print_prompt - "Linked to custom clone directory: ${newCloneDir}"
[[ -n ${GIT} ]] && print_prompt -"Custom repository from: ${GIT}"
# Set default values if not provided
newCloneDir=${newCloneDir:-${HOME}/.cache/hyde/Hyde-Clone}
#TODO Change this to the upstream
# GIT=${GIT:-"https://github.com/prasanthrangan/hyde"}
GIT=${GIT:-"https://github.com/prasanthrangan/hyprdots"}
export newCloneDir
export GIT
export CloneDir=${newCloneDir}
if ! main; then print_prompt -crit "[error] " "Hyde-istall Terminated"; fi