USB OFFLINE: Ubuntu 24.04 setup /etc/rc.local
Revision as of 15:34, 29 April 2024 by Onnowpurbo (talk | contribs) (→=Script Startup yang panjang)
Ubuntu 24.04 – start program after boot
Edit
sudo vi /etc/rc.local
Isi dengan
#!/bin/sh -e <your_program>.sh
exit 0
Save file rc.local
Pastikan file script bisa di jalankan dengan chmod
chmod 777 <your_program>.sh chmod +x <your_program>.sh
make rc.local executable:
sudo chmod +x /etc/rc.local sudo chmod -Rf 744 /etc/rc.local
edit /etc/systemd/system/rc-local.service:
sudo nano /etc/systemd/system/rc-local.service
tambahkan content berikut ke rc.local.service:
# SPDX-License-Identifier: LGPL-2.1+ # # This file is part of systemd. # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. # This unit gets pulled automatically into multi-user.target by # systemd-rc-local-generator if /etc/rc.local is executable. [Unit] Description=/etc/rc.local Compatibility Documentation=man:systemd-rc-local-generator(8) ConditionFileIsExecutable=/etc/rc.local After=network.target [Service] Type=forking ExecStart=/etc/rc.local start TimeoutSec=0 RemainAfterExit=yes GuessMainPID=no [Install] WantedBy=multi-user.target
enable rc.local by service:
sudo systemctl enable rc-local.service
start rc.local by service:
sudo systemctl start rc-local.service
check rc.local status:
sudo systemctl status rc-local.service
=isi rc.local
#!/bin/sh -e /home/offline/start-OFFLINE-server.sh exit 0
Script Startup yang panjang
vi /home/offline/start-OFFLINE-server.sh
# Edit file config moodle # /var/www/html/moodle/config.php # # Pastikan IP address moodle sesuai dengan IP yang digunakan server # misalnya 192.168.88.2, # $CFG->wwwroot = 'http://192.168.88.2/moodle'; # Sesuaikan dengan nama interface & IP address yang anda mau # /usr/sbin/dhclient enp0s31f6 # /usr/sbin/ifconfig enp0s31f6:88 192.168.88.2 # /usr/sbin/ifconfig enp0s31f6:200 192.168.0.200 # /usr/sbin/ifconfig enp0s31f6:200 192.168.1.2 /usr/sbin/dhclient enp2s0 # /usr/sbin/ifconfig enp2s0:88 192.168.88.2 # /usr/sbin/ifconfig enp2s0:200 192.168.0.200 # /usr/sbin/ifconfig enp2s0:200 192.168.1.2 /usr/sbin/dhclient enp3s0 # /usr/sbin/ifconfig enp3s0:88 192.168.88.2 # /usr/sbin/ifconfig enp3s0:200 192.168.0.200 # /usr/sbin/ifconfig enp3s0:200 192.168.1.2 /usr/bin/kiwix-serve --port=8080 /var/www/html/kiwix/wikipedia_id_top_maxi_2024-04.zim &