-
Notifications
You must be signed in to change notification settings - Fork 0
/
mkosi.postinst
executable file
·172 lines (146 loc) · 6.72 KB
/
mkosi.postinst
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
#!/bin/sh
export DEBIAN_FRONTEND=noninteractive
. /etc/os-release
echo $UBUNTU_CODENAME
mkdir -p /etc/apt
echo deb http://archive.ubuntu.com/ubuntu/ $UBUNTU_CODENAME main restricted universe multiverse > /etc/apt/sources.list
echo deb http://archive.ubuntu.com/ubuntu/ $UBUNTU_CODENAME-updates main restricted universe multiverse >> /etc/apt/sources.list
echo deb http://security.ubuntu.com/ubuntu/ $UBUNTU_CODENAME-security main restricted universe multiverse >> /etc/apt/sources.list
apt-get update -qq
#setup systemd (from https://github.com/solita/docker-systemd/blob/master/Dockerfile)
apt-get install -qy systemd dbus libpam-systemd systemd-container net-tools tzdata
#find /etc/systemd/system \
# /lib/systemd/system \
# -path '*.wants/*' \
# -not -name '*journald*' \
# -not -name '*systemd-tmpfiles*' \
# -not -name '*systemd-user-sessions*' \
# -exec rm \{} \;
systemctl set-default multi-user.target
mkdir -p /etc/systemd/system/
cp /install-files/install/system-first-run.service /etc/systemd/system/system-first-run.service
cp /install-files/install/system-update.service /etc/systemd/system/system-update.service
systemctl enable system-first-run.service
systemctl enable system-update.service
chmod 755 /install-files/install/system-first-run.sh
chmod 755 /install-files/install/system-update.sh
chmod 755 /install-files/install/user-first-run.sh
chmod 755 /install-files/install/user-update.sh
chmod 755 /install-files/settings/audioserver_restart_broadcast.sh
mkdir -p /etc/systemd/network
ln -s /settings/60-host0.network /etc/systemd/network --force
ln -s /settings/hostname /etc/hostname --force
systemctl enable systemd-networkd.service
systemctl enable systemd-resolved.service
#ln -s ../system-first-run.service /etc/systemd/system/multi-user.target.wants/
# create config directory
mkdir -p /settings
cp -Rf /install-files/settings/* /settings/
mkdir -p /media/music/playlists
cp -Rf /install-files/playlists/* /media/music/playlists
cp /etc/timezone /settings
ln -sf /settings/timezone /etc/timezone
# setup basic stuff and build tools
apt-get install -qy build-essential pulseaudio libpam-systemd git autotools-dev autoconf libtool gettext gawk gperf libunistring-dev libsqlite3-dev libavcodec-dev libavformat-dev libavfilter-dev libswscale-dev libavutil-dev libasound2-dev libpulse-dev libevent-dev libavahi-client-dev
#apt-get install -qy dbus-user-session # this can be used instead of custom user dbus.socket
mkdir -p /build
# setup icecast
apt-get install -qy gstreamer1.0-plugins-ugly lame gstreamer1.0-plugins-good ffmpeg gstreamer1.0-pulseaudio
mkdir /etc/icecast2
apt-get install -qy icecast2
ln -sf /settings/icecast.xml /etc/icecast2/
chmod 755 /settings/icecast.xml
ffmpeg -f lavfi -i aevalsrc=0 -t 5 /usr/share/icecast2/web/silence.mp3
sed -i -e 's/false/true/g' /etc/default/icecast2
#systemctl enable icecast2
# setup snapcast
apt-get install -qy libasound2-dev libvorbisidec-dev libvorbis-dev libflac-dev alsa-utils libavahi-client-dev avahi-daemon
cd /build
git clone https://github.com/badaix/snapcast.git
cd snapcast
git checkout tags/v0.15.0
cd externals
git submodule update --init --recursive
cd ../server
make
cp snapserver /usr/local/bin
# setup librespot
apt-get install -qy portaudio19-dev cmake python2.7 wget
#cd /build
#git clone https://github.com/rust-lang/rust.git
#cd rust
#git checkout tags/1.17.0
#./configure
#make && make install
cd /build
wget https://static.rust-lang.org/rustup/rustup-init.sh
chmod +x rustup-init.sh
./rustup-init.sh -y --default-toolchain stable
export PATH="$HOME/.cargo/bin:$PATH"
cd /build
git clone https://github.com/librespot-org/librespot.git
cd librespot
#git checkout d95c0b3fcd2ddfa9d09a189d73b82090420d7f56
cargo build --release --features "pulseaudio-backend"
cp target/release/librespot /usr/local/bin
# setup mopidy
apt-get install -qy python3-dev python3-gst-1.0 gir1.2-gstreamer-1.0 gir1.2-gst-plugins-base-1.0 gstreamer1.0-plugins-good gstreamer1.0-plugins-ugly gstreamer1.0-tools wget python-setuptools gstreamer1.0-pulseaudio libffi-dev python-dbus
apt-get install -qy python3-pip
#cd /build
pip install -U Mopidy==3.3.0
#pip install -U Mopidy-Iris==2.13.12 Mopidy-Local-SQLite==1.0.0 Mopidy-Moped==0.7.0
#pip install -U Mopidy-MPRIS==1.3.1
#pip install -U Mopidy
#pip install -U Mopidy-Iris Mopidy-Local-SQLite Mopidy-Moped Mopidy-MPRIS
# setup way to control Mopidy with command line
apt-get install -qy python3-pip mpc
pip3 install -U pydbus
cp /install-files/install/control_mopidy_mpc.py /usr/local/bin
cp /install-files/install/control_mopidy_dbus.py /usr/local/bin
# setup shairport-sync
apt-get install -qy shairport-sync
# setup systemd configurations
ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf --force
mkdir -p /etc/systemd/journald.conf.d
echo [Journal] > /etc/systemd/journald.conf.d/limit-size.conf
echo SystemMaxUse=100M >> /etc/systemd/journald.conf.d/limit-size.conf
echo RuntimeMaxUse=100M >> /etc/systemd/journald.conf.d/limit-size.conf
# setup user audioserver
adduser --disabled-password --gecos "" audioserver
ln -s /settings/home_audioserver_.config /home/audioserver/.config
mkdir -p /home/audioserver/.config/systemd/user/default.target.wants/
ln -s ../user-first-run.service /home/audioserver/.config/systemd/user/default.target.wants/
ln -s ../user-update.service /home/audioserver/.config/systemd/user/default.target.wants/
ln -s /settings/home_audioserver_.asoundrc /home/audioserver/.asoundrc
chown -R audioserver:audioserver /settings/home_audioserver_.config
chown -R audioserver:audioserver /settings/home_audioserver_.asoundrc
chown -R audioserver:audioserver /home/audioserver/.config
chown -R audioserver:audioserver /home/audioserver/.asoundrc
chmod 755 /settings/home_audioserver_.config
mkdir -p /settings/audioserver
chown -R audioserver:audioserver /settings/audioserver
chmod 755 /settings/audioserver
cp /install-files/install/etc_security_limits_d_audioserver.conf /etc/security/limits.d/
# setup navidrome
cd /build
wget https://github.com/navidrome/navidrome/releases/download/v0.51.0/navidrome_0.51.0_linux_amd64.tar.gz -O Navidrome.tar.gz
tar xvzf Navidrome.tar.gz -C /opt/navidrome/
adduser --system --no-create-home --group navidrome
mkdir -p /var/lib/navidrome
echo MusicFolder = \"/music\" > /settings/navidrome.toml
ln -s /settings/navidrome.toml /val/lib/navidrome.toml
chown -R navidrome:navidrome /var/lib/navidrome
systemctl enable navidrome
# setup bonob
apt-get install libvips-dev
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
nvm install 20
cd /opt
git clone https://github.com/simojenki/bonob.git
cd bonob
npm install && npm test && npm run gitinfo && npm run build && echo fertig
NODE_ENV=production npm install --omit=dev
cp build/src/* src
systemctl enable bonob
rm -rf /build
exit