Skip to content

Commit

Permalink
Final touches for initial stable build
Browse files Browse the repository at this point in the history
  • Loading branch information
xaqbr committed Jun 21, 2024
1 parent c66e1e5 commit 7e1cb97
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 21 deletions.
91 changes: 71 additions & 20 deletions userpatches/customize-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,19 @@ BUILD_DESKTOP=$4

Main() {
# =========================================================================
# Source overlay environment configuration.
# Pre-initialization steps.
# =========================================================================
# Source overlay environment configuration.
set -a
source /tmp/overlay/env
set +a

# =========================================================================
# Copy overlay filesystem & other files to root.
# =========================================================================
cp -r /tmp/overlay/rootfs/* /
cp /tmp/overlay/cert.pem /etc/rauc
# Generate locales.
export LANG=C LC_ALL="en_US.UTF-8"
locale-gen en_US.UTF-8

sed -i "s#::HAWKBIT_SERVER_URL::#$HAWKBIT_SERVER_URL#" /etc/rauc/hawkbit.conf
sed -i "s/::HAWKBIT_GATEWAY_TOKEN::/$HAWKBIT_GATEWAY_TOKEN/" /etc/rauc/hawkbit.conf
# Update hostname.
echo "dmbpro" > /etc/hostname

# =========================================================================
# Install drivers, software packages and update system.
Expand All @@ -51,15 +50,31 @@ Main() {
# - cmake Build tools needed for gnome-monitor-config.
# - libcairo2-dev
# - gettext Build tools needed for Gnome Hide Top Bar extension.
# - php-xml Packages needed for Laravel application.
# - php-dom
# - php-sqlite3
# - composer
# - npm
# - apache2 Web server.
# - libapache2-mod-php
# =========================================================================
export DEBIAN_FRONTEND="noninteractive"
export APT_LISTCHANGES_FRONTEND="none"
add-apt-repository -y ppa:jjriek/panfork-mesa
add-apt-repository -y ppa:liujianfeng1994/rockchip-multimedia
apt-get update -y
apt-get install -y systemd-repart mali-g610-firmware rockchip-multimedia-config rauc-service libubootenv-tool meson libcurl4-openssl-dev libjson-glib-dev chromium-browser python3-shortuuid vim cmake libcairo2-dev gettext
apt-get install -y systemd-repart mali-g610-firmware rockchip-multimedia-config rauc-service libubootenv-tool meson libcurl4-openssl-dev libjson-glib-dev chromium-browser python3-shortuuid vim cmake libcairo2-dev gettext php-xml php-dom php-sqlite3 composer apache2 libapache2-mod-php npm
apt-get dist-upgrade -y

# =========================================================================
# Copy overlay filesystem & other files to root.
# =========================================================================
cp -r /tmp/overlay/rootfs/* /
cp /tmp/overlay/cert.pem /etc/rauc

sed -i "s#::HAWKBIT_SERVER_URL::#$HAWKBIT_SERVER_URL#" /etc/rauc/hawkbit.conf
sed -i "s/::HAWKBIT_GATEWAY_TOKEN::/$HAWKBIT_GATEWAY_TOKEN/" /etc/rauc/hawkbit.conf

# =========================================================================
# Build and install rauc-hawkbit-updater
# =========================================================================
Expand All @@ -83,30 +98,63 @@ Main() {
# Setup main user
# =========================================================================
rm /root/.not_logged_in_yet # Disable Armbian interactive setup.
useradd -m -d /home/dmb -s /bin/bash dmb
echo "dmb:$USER_PASSWORD" | chpasswd
for new_group in sudo netdev audio video disk tty users games dialout plugdev input bluetooth systemd-journal ssh render; do
usermod -aG "${new_group}" dmb 2> /dev/null
useradd -m -d /home/dmbuser -s /bin/bash dmbuser
echo "dmbuser:$APP_USER_PASSWORD" | chpasswd
for new_group in netdev audio video disk tty users games dialout plugdev input bluetooth systemd-journal ssh render; do
usermod -aG "${new_group}" dmbuser 2> /dev/null
done
export LANG=C LC_ALL="en_US.UTF-8"
locale-gen en_US.UTF-8
{
echo "export LANG=en_US.UTF-8"
echo "export LANGUAGE=en_US"
} >> /home/dmb/.bashrc
} >> /home/dmbuser/.bashrc
{
echo "export LANG=en_US.UTF-8"
echo "export LANGUAGE=en_US"
} >> /home/dmb/.xsessionrc
mkdir -p /home/dmb/.config/autostart && cp /tmp/overlay/autostart/* /home/dmb/.config/autostart
} >> /home/dmbuser/.xsessionrc
mkdir -p /home/dmbuser/.config/autostart && cp /tmp/overlay/autostart/* /home/dmbuser/.config/autostart

# =========================================================================
# Setup developer user
# =========================================================================
useradd -m -d /home/dev -s /bin/bash dev
echo "dev:$DEV_USER_PASSWORD" | chpasswd
for new_group in sudo netdev audio video disk tty users games dialout plugdev input bluetooth systemd-journal ssh render www-data; do
usermod -aG "${new_group}" dev 2> /dev/null
done

# =========================================================================
# Build and install Gnome hide top bar
# =========================================================================
git clone https://gitlab.gnome.org/tuxor1337/hidetopbar.git /tmp/hidetopbar
cd /tmp/hidetopbar
make
sudo -Hu dmb gnome-extensions install ./hidetopbar.zip
sudo -Hu dmbuser gnome-extensions install ./hidetopbar.zip

# =========================================================================
# Retrieve and install main application.
# =========================================================================
# Retrieve and setup application from remote repository.
export COMPOSER_MAX_PARALLEL_HTTP=4
git clone https://$APP_REPOSITORY_USER:$APP_REPOSITORY_TOKEN@github.com/$APP_REPOSITORY_PATH /srv/dmbpro
git -C /srv/dmbpro remote set-url origin git@github.com:$APP_REPOSITORYPATH
cp /srv/dmbpro/.env.dmbp /srv/dmbpro/.env
chown -R www-data:www-data /srv/dmbpro # Set ownership to www-data
sudo -Hu www-data composer -d /srv/dmbpro install --no-dev
php /srv/dmbpro/artisan key:generate --force
php /srv/dmbpro/artisan migrate --force
php /srv/dmbpro/artisan optimize
php /srv/dmbpro/artisan config:cache
php /srv/dmbpro/artisan event:cache
php /srv/dmbpro/artisan route:cache
php /srv/dmbpro/artisan view:cache
chown -R www-data:www-data /srv/dmbpro # Set ownership to www-data
chmod -R g+w /srv/dmbpro # Enable group write permissions
chmod -R o-r /srv/dmbpro # Disable other user read permissions

# Install new site to Apache2 configuration.
a2enmod rewrite
a2dissite 000-default
a2ensite dmbp

# =========================================================================
# Enable desktop manager auto-login.
Expand All @@ -115,7 +163,7 @@ Main() {
cat <<- EOF > /etc/gdm3/custom.conf
[daemon]
AutomaticLoginEnable = true
AutomaticLogin = dmb
AutomaticLogin = dmbuser
EOF
ln -sf /lib/systemd/system/gdm3.service /etc/systemd/system/display-manager.service

Expand All @@ -124,6 +172,9 @@ EOF
# =========================================================================
systemctl enable dmbp-updater
systemctl enable dmbp-install-armbian
systemctl enable dmbp-app-queue-worker
systemctl enable dmbp-app-schedule-worker
systemctl enable ssh

# Setup WiFi/Bluetooth drivers for Orange Pi 5B. At this time, Armbian
# doesn't support the board natively, so must configure this manually.
Expand Down
6 changes: 5 additions & 1 deletion userpatches/overlay/env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
USER_PASSWORD=""
APP_USER_PASSWORD=""
DEV_USER_PASSWORD=""
HAWKBIT_SERVER_URL=""
HAWKBIT_GATEWAY_TOKEN=""
APP_REPOSITORY_PATH=""
APP_REPOSITORY_USER=""
APP_REPOSITORY_TOKEN=""
13 changes: 13 additions & 0 deletions userpatches/overlay/rootfs/etc/apache2/sites-available/dmbp.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<VirtualHost *:80>
DocumentRoot /srv/dmbpro/public
ServerAdmin support@digitalmovieboards.com

<Directory /srv/dmbpro/public>
Options +FollowSymlinks
AllowOverride All
Require all granted
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Launch Laravel schedule worker.
[Unit]
Description=DMBP Services - App Queue Worker
After=apache2.service

[Service]
Type=simple
Restart=always
RestartSec=1
ExecStart=sudo -Hu www-data /srv/dmbpro/artisan queue:work

[Install]
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Launch Laravel schedule worker.
[Unit]
Description=DMBP Services - App Schedule Worker
After=apache2.service

[Service]
Type=simple
Restart=always
RestartSec=1
ExecStart=sudo -Hu www-data /srv/dmbpro/artisan schedule:work

[Install]
WantedBy=multi-user.target

0 comments on commit 7e1cb97

Please sign in to comment.