-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·117 lines (77 loc) · 2.53 KB
/
setup.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
#!/usr/bin/env bash
# https://superuser.com/a/202654
CURRENT_DIR="$(readlink -f $(dirname "${BASH_SOURCE[0]}"))"
DOMAIN="read.tug.ro"
USER="$(whoami)"
DOTFILES_SYSTEM_DIR="$CURRENT_DIR/../dotfiles-system"
DOTFILES_SYSTEM_GIT_REPO="https://github.com/musq/dotfiles-system.git"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Setup dotfiles-system dir
if [ ! -d "$DOTFILES_SYSTEM_DIR" ]; then
git clone --recurse-submodules \
"$DOTFILES_SYSTEM_GIT_REPO" \
"$DOTFILES_SYSTEM_DIR"
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Source utility functions
. "$DOTFILES_SYSTEM_DIR/src/os/utils.sh" \
&& . "$DOTFILES_SYSTEM_DIR/src/os/contract/utils.sh" \
&& . "$DOTFILES_SYSTEM_DIR/src/os/install/nix/utils.sh"
cd "$CURRENT_DIR"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Ask sudo password, if necessary
if [ "$(user_has_sudo)" != "no_sudo" ]; then
ask_for_sudo
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Postgres
print_in_purple "\n ● Postgres\n\n"
execute \
"$NIX_DEFAULT_BIN/createuser miniflux" \
"Create user: miniflux" \
"sudo" \
"postgres"
execute \
"$NIX_DEFAULT_BIN/createdb \
--owner=miniflux \
miniflux" \
"Create database: miniflux" \
"sudo" \
"postgres"
execute \
"$NIX_DEFAULT_BIN/psql \
miniflux -c \\\"CREATE EXTENSION IF NOT EXISTS hstore\\\"" \
"Create extension: hstore" \
"sudo" \
"postgres"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Miniflux
print_in_purple "\n ● Miniflux\n\n"
nix_install "Miniflux" "nixpkgs.miniflux"
add_user "miniflux" "Miniflux" "system"
# execute \
# "miniflux -config-file $(pwd)/miniflux.conf -migrate"
# "Run migrations"
# "sudo"
# Create miniflux user account
create_symlink "$(pwd)/miniflux.service" "/lib/systemd/system/miniflux.service" "-y"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Nginx
print_in_purple "\n ● Nginx\n\n"
create_symlink \
"$(pwd)/$DOMAIN.conf" \
"/etc/nginx/conf.d/$DOMAIN.conf" "-y"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Systemd
print_in_purple "\n ● Systemd\n\n"
execute \
"systemctl enable miniflux \
&& systemctl reload-or-restart miniflux" \
"Reload Miniflux" \
"sudo"
execute \
"systemctl enable nginx \
&& systemctl reload-or-restart nginx" \
"Reload Nginx" \
"sudo"
print_in_purple "\n"