summaryrefslogtreecommitdiffstats
path: root/scripts/install-dependencies.sh
blob: 1e67bdafb1eb98cd12916e30842bc6996cb51383 (plain)
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#!/bin/sh
#
# Script that installs the various dependencies of invidious
#
# Dependencies:
# - crystal       => Language in which Invidious is developed
# - postgres      => Database server
# - git           => required to clone Invidious
# - librsvg2-bin  => For login captcha (provides 'rsvg-convert')
#
# - libssl-dev    => Used by Crystal's SSL module (standard library)
# - libxml2-dev   => Used by Crystal's XML module (standard library)
# - libyaml-dev   => Used by Crystal's YAML module (standard library)
# - libgmp-dev    => Used by Crystal's BigNumbers module (standard library)
# - libevent-dev  => Used by crystal's internal scheduler (?)
# - libpcre3-dev  => Used by Crystal's regex engine (?)
#
# - libsqlite3-dev   => Used to open .db files from NewPipe exports
# - zlib1g-dev       => TBD
# - libreadline-dev  => TBD
#
#
# Tested on:
# - OpenSUSE Leap 15.3

#
# Load system details
#

if [ -e /etc/os-release ]; then
	. /etc/os-release
elif [ -e /usr/lib/os-release ]; then
	. /usr/lib/os-release
else
	echo "Unsupported Linux system"
	exit 2
fi

#
# Some variables
#

repo_base_url="https://download.opensuse.org/repositories/devel:/languages:/crystal/"
repo_end_url="devel:languages:crystal.repo"

apt_gpg_key="/usr/share/keyrings/crystal.gpg"
apt_list_file="/etc/apt/sources.list.d/crystal.list"

yum_repo_file="/etc/yum.repos.d/crystal.repo"

#
# Major install functions
#

make_repo_url() {
	echo "${repo_base_url}/${1}/${repo_end_url}"
}


install_apt() {
	repo="$1"

	echo "Adding Crystal repository"

	curl -fsSL "${repo_base_url}/${repo}/Release.key" \
		| gpg --dearmor \
		| sudo tee "${apt_gpg_key}" > /dev/null

	echo "deb [signed-by=${apt_gpg_key}] ${repo_base_url}/${repo}/ /" \
		| sudo tee "$apt_list_file"

	sudo apt-get update

	sudo apt-get install --yes --no-install-recommends \
		libssl-dev libxml2-dev libyaml-dev libgmp-dev libevent-dev \
		libpcre3-dev libreadline-dev libsqlite3-dev zlib1g-dev \
		crystal postgresql-13 git librsvg2-bin make
}

install_yum() {
	repo=$(make_repo_url "$1")

	echo "Adding Crystal repository"

	cat << END | sudo tee "${yum_repo_file}" > /dev/null
[crystal]
name=Crystal
type=rpm-md
baseurl=${repo}/
gpgcheck=1
gpgkey=${repo}/repodata/repomd.xml.key
enabled=1
END

	sudo yum -y install \
		openssl-devel libxml2-devel libyaml-devel gmp-devel \
		readline-devel sqlite-devel \
		crystal postgresql postgresql-server git librsvg2-tools make
}

install_pacman() {
	# TODO: find an alternative to --no-confirm?
	sudo pacman -S --no-confirm \
		base-devel librsvg postgresql crystal
}

install_zypper()
{
	repo=$(make_repo_url "$1")

	echo "Adding Crystal repository"
	sudo zypper --non-interactive addrepo -f "$repo"

	sudo zypper --non-interactive --gpg-auto-import-keys install --no-recommends \
		libopenssl-devel libxml2-devel libyaml-devel gmp-devel libevent-devel \
		pcre-devel readline-devel sqlite3-devel zlib-devel \
		crystal postgresql postgresql-server git rsvg-convert make
}


#
# System-specific logic
#

case "$ID" in
	archlinux) install_pacman;;

	centos) install_dnf "CentOS_${VERSION_ID}";;

	debian)
		case "$VERSION_CODENAME" in
			sid)      install_apt "Debian_Unstable";;
			bookworm) install_apt "Debian_Testing";;
			*)        install_apt "Debian_${VERSION_ID}";;
		esac
	;;

	fedora)
		if [ "$VERSION" == *"Prerelease"* ]; then
			install_dnf "Fedora_Rawhide"
		else
			install_dnf "Fedora_${VERSION}"
		fi
	;;

	opensuse-leap) install_zypper "openSUSE_Leap_${VERSION}";;

	opensuse-tumbleweed) install_zypper "openSUSE_Tumbleweed";;

	rhel) install_dnf "RHEL_${VERSION_ID}";;

	ubuntu)
		# Small workaround for recently released 22.04
		case "$VERSION_ID" in
			22.04) install_apt "xUbuntu_21.04";;
			*)     install_apt "xUbuntu_${VERSION_ID}";;
		esac
	;;

	*)
		# Try to match on ID_LIKE instead
		# Not guaranteed to 100% work
		case "$ID_LIKE" in
			archlinux) install_pacman;;
			centos) install_dnf "CentOS_${VERSION_ID}";;
			debian) install_apt "Debian_${VERSION_ID}";;
			*)
				echo "Error: distribution ${CODENAME} is not supported"
				echo "Please install dependencies manually"
				exit 2
			;;
		esac
	;;
esac
> 2021-04-10add insta.trom.tfalefvanoon 2021-04-10add search.trom.tfalefvanoon 2021-04-09add searx.silkky.cloudalefvanoon 2021-04-09add libreddit.silkky.cloudalefvanoon 2021-04-09add some invidious insalefvanoon 2021-04-09add some invidious insalefvanoon 2021-04-09refactor: drop teddit image redirect supportJason Kim No longer redirect image links for teddit instances. Add a comment detailing the two issues I found. Now, the feature should be stable. 2021-04-09fix: don't redirect for rest of instancesJason Kim Unbreak old.reddit.com and i.reddit.com by ignoring image redirects for them. 2021-04-08fix: redirect teddit differentlyJason Kim Teddit image urls are different from libreddit. Handle each separately. Test manually: - libredd.it: pass - libreddit.spike.codes: pass - libreddit.kavin.rocks: pass - libreddit.insanity.wtf: fail (site doesn't work in general) - libreddit.dothq.co: pass - teddit.net: mostly fail - teddit.ggc-project.de: mostly fail - teddit.kavin.rocks: mostly fail - old.reddit.com: fail - i.reddit.com: fail - snew.notabug.io: fail (site doesn't work in general) Teddit image urls have two issues. First, the links almost never work (404) if the image url is visited directly before visiting the main page. Once the main page is visited, however, the image url starts working. I'm guessing this is an issue with teddit instances not fetching images unless the main page is accessed. Second, some image links are different/incompatible for some reason. For example, <https://i.redd.it/htg3owj12ok21.png> turns into <https://teddit.net/pics/w:null_TpEyuHnjif6578pV0lBuM-kNW1bXqxbvqbOHjhRZVr0.png>. Libreddit seems to not have this issue. 2021-04-08feat: add img prefix for i.redd.itJason Kim "i.redd.it/<imgfile>" redirects "libredd.it/<imgfile>". Make it redirect to "libredd.it/img/<imgfile>". Tested only for "libredd.it". 2021-04-08feat: add i.redd.it to reddit targetsJason Kim Add "i.redd.it" to list of urls to redirect for Reddit. Although the redirect works, the link should be invalid because it still needs an "img" path prefix. 2021-04-07Update Bibliogram instances listCadence Ember Set it to match the list of actually working instances. https://git.sr.ht/~cadence/bibliogram-docs/tree/master/docs/Instances.md 2021-04-05Update manifest.jsonHarsh Barsaiyan 2021-03-30Add ViewTubeHarsh Barsaiyan 2021-03-20Add Ecosia search engineCamille019 2021-03-11Add Whoogle SearchHarsh Barsaiyan 2021-03-02Disable SimplyTranslate redirects by defaultfattalion 2021-02-25Add SimplyTranslate supportfattalion 2021-02-24add invidious instanceAndrew Zhao