forked from 51sec/xrdp4arm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
138 lines (119 loc) · 11.1 KB
/
install.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#/bin/bash
# Ubuntu20 desktop configuration (arm supported)
# quit immediately if there is an error
set -e
# ...
set -x
# Xrdp
function install_xrdp() {
apt-get install -y xrdp
}
# install desktop environment lxde.
function install_desktop_env() {
DEBIAN_FRONTEND=noninteractive apt-get install -y lxde
}
# Xrdp PulseAudio
function install_xrdp_pa() {
apt-get install -y git libpulse-dev autoconf m4 intltool build-essential dpkg-dev libtool libsndfile1-dev libspeexdsp-dev libudev-dev pulseaudio
cp /etc/apt/sources.list /etc/apt/sources.list.u2ad
sed -Ei 's/^# deb-src /deb-src /' /etc/apt/sources.list
apt-get update -y
apt build-dep pulseaudio -y
cd /tmp
apt source pulseaudio
pulsever=$(pulseaudio --version | awk '{print $2}')
cd /tmp/pulseaudio-$pulsever
# ./configure --without-caps
./configure
git clone https://github.com/neutrinolabs/pulseaudio-module-xrdp.git
cd pulseaudio-module-xrdp
./bootstrap
./configure PULSE_DIR="/tmp/pulseaudio-$pulsever"
make
cd /tmp/pulseaudio-$pulsever/pulseaudio-module-xrdp/src/.libs
install -t "/var/lib/xrdp-pulseaudio-installer" -D -m 644 *.so
# systemctl restart dbus
# systemctl restart pulseaudio
systemctl restart xrdp
# Issue: https://github.com/neutrinolabs/pulseaudio-module-xrdp/issues/44
fix_pa_systemd_issue
}
# resolve PA no sound issue
# Issue: https://github.com/neutrinolabs/pulseaudio-module-xrdp/issues/44
function fix_pa_systemd_issue() {
mkdir -p /home/rdpuser/.config/systemd/user/
ln -s /dev/null /home/rdpuser/.config/systemd/user/pulseaudio.service
mkdir -p /home/rdpuser/.config/autostart/
cat <<EOF | \
sudo tee /home/rdpuser/.config/autostart/pulseaudio.desktop
[Desktop Entry]
Type=Application
Exec=pulseaudio
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name[en_US]=pulseaudio
Name=pulseaudio
Comment[en_US]=pulseaudio
Comment=pulseaudio
EOF
chown -R rdpuser /home/rdpuser/.config/
chmod -R 755 /home/rdpuser/.config/
}
# create desktop user
function create_desktop_user() {
useradd -s /bin/bash -m rdpuser
usermod -a -G sudo rdpuser
echo "rdpuser ALL=(ALL) ALL" >> /etc/sudoers
echo "rdpuser_password
rdpuser_password
" | passwd rdpuser
}
# Xrdp environment configuration
function xrdp_conf() {
touch /home/rdpuser/.Xclients
echo "lxsession" > /home/rdpuser/.Xclients
chmod a+x /home/rdpuser/.Xclients
# sudo sed -e 's/^new_cursors=true/new_cursors=false/g' -i /etc/xrdp/xrdp.ini
cp /etc/xrdp/xrdp.ini /etc/xrdp/xrdp.ini.backup.u2ad
echo "$xrdp_config_base64" | base64 -d > /etc/xrdp/xrdp.ini
cat <<EOF | \
sudo tee /etc/polkit-1/localauthority/50-local.d/xrdp-color-manager.pkla
[Netowrkmanager]
Identity=unix-user:*
Action=org.freedesktop.color-manager.create-device
ResultAny=no
ResultInactive=no
ResultActive=yes
EOF
systemctl restart xrdp
systemctl restart polkit
}
# desktop environment configuration
function desktop_env_conf() {
# remove network icon
apt-get remove -y network-manager-gnome
# chrome has no arm64 version, install chromium
apt-get install -y chromium-browser
}
apt-get update -y
apt-get install -y sudo screen
# create a desktop user
create_desktop_user
# Install desktop environment
install_desktop_env
# install XRDP
install_xrdp
# install XRDP PA
install_xrdp_pa
# XRDP Environment Configuration
xrdp_config_base64="W0dsb2JhbHNdDQo7IHhyZ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WFzazMzODkNCiMgdXNlcm5hbWU9YXNrDQojIHBhc3N3b3JkPWFzaw0KDQo7IFlvdSBjYW4gb3ZlcnJpZGUgdGhlIGNvbW1vbiBjaGFubmVsIHNldHRpbmdzIGZvciBlYWNoIHNlc3Npb24gdHlwZQ0KI2NoYW5uZWwucmRwZHI9dHJ1ZQ0KI2NoYW5uZWwucmRwc25kPXRydWUNCiNjaGFubmVsLmRyZHludmM9dHJ1ZQ0KI2NoYW5uZWwuY2xpcHJkcj10cnVlDQojY2hhbm5lbC5yYWlsPXRydWUNCiNjaGFubmVsLnhyZHB2cj10cnVlDQo="
xrdp_conf
# Desktop Environment Configuration
desktop_env_conf
apt-get autoremove -y
echo "Install Done!"
echo "Now you can reboot and connect port 3389 with rdp client"
echo "Note: chromium-browser is not displayed on the desktop, please start it manually if necessary"
echo "Default Username: rdpuser"
echo "Default Password: rdpuser_password"