blob: 345c5efac063bb9a7c27faf784c2810d69494b3a (
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
|
#!/usr/bin/env bash
# Copyright (C) 2023 The Qt Company Ltd.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
set -ex
systemd_folder=/etc/systemd/system
systemd_file=dummysound.service
script_folder=/home/qt/bin
script_file=dummy_sound.sh
# Create script to install dummy sound driver,
# in case no other sound driver is installed.
sudo tee "${script_folder}/${script_file}" <<"EOF"
# Check for existing sound driver
if lsmod | grep -q -i snd
then
echo "(**) Sound driver already loaded. Nothing to do.";
exit 0;
fi
# load dummy sound module
sudo modprobe snd-dummy
# Check result
if lsmod | grep -q snd_dummy
then
echo "(**) Dummy sound driver loaded.";
else
echo "(EE) Failed to load dummy sound driver.";
exit 1;
fi
EOF
# set permissions
sudo chmod 750 "${script_folder}/${script_file}"
# Create service file
sudo tee "${systemd_folder}/${systemd_file}" <<"EOF"
# /etc/systemd/system/dummysound.service
#
[Unit]
Description=Install dummy sound driver
[Service]
Type=oneshot
ExecStart=/bin/sh -c "/home/qt/bin/dummy_sound.sh"
[Install]
WantedBy=multi-user.target
EOF
# Start servive and output result, just for logging
sudo systemctl start dummysound.service
# status commented out, returns 3 on VM.
# sudo systemctl status dummysound.service
# enable service
sudo systemctl enable dummysound.service
|