25 changed files with 1116 additions and 13 deletions
@ -0,0 +1,99 @@ |
|||
#cloud-config |
|||
|
|||
autoinstall: |
|||
version: 1 |
|||
early-commands: |
|||
# delete any old partition data, up to 240MB size, if this was reinstall |
|||
# erases partition tables and whole boot partition as well, by erasing 30x8MB=240MB (partition is 200MB) |
|||
- dd if=/dev/zero of=/dev/sda bs=8M count=30 |
|||
# create new 200MB boot partition and rest as root partition |
|||
- (echo o; echo n; echo p; echo 1; echo ""; echo +200M; echo n; echo p; echo 2; echo ''; echo ''; echo a; echo 1; echo p; echo w) | fdisk /dev/sda |
|||
# format boot as FAT 32 |
|||
- mkfs.fat -F 32 -D 0x80 -M 0xF8 -n BOOT /dev/sda1 |
|||
# format rest as ext4 |
|||
- mkfs.ext4 -F /dev/sda2 |
|||
# create mount points for boot and root |
|||
- mkdir /mnt/boot /mnt/root |
|||
# don't mount boot yet, as later syslinux requires it unmounted, or mount it here and unmount before syslinux -i |
|||
# - mount /dev/sda1 /mnt/boot |
|||
- mount /dev/sda2 /mnt/root |
|||
# optional commands to see what's mounted, note if you did not mount it, don't ls it because subiquity installer will fail |
|||
# - df -h |
|||
# - ls -al /mnt |
|||
# - ls -al /mnt/boot |
|||
# - ls -al /mnt/root |
|||
# download ubuntu Base from official repo, we download 20.10 below, this will download to / (root) of ubiquity installer, which means - into memory |
|||
# if you want 20.04 or 20.10 or anything else (future releases) just change following these two lines (curl and tar) to reflect that, plus later in script change kernel version |
|||
- curl http://cdimage.ubuntu.com/ubuntu-base/releases/20.10/release/ubuntu-base-20.10-base-amd64.tar.gz -o /ubuntu-base-20.10-base-amd64.tar.gz |
|||
# extract all files to our sda2, mounted at /mnt/root |
|||
- tar -xzvf /ubuntu-base-20.10-base-amd64.tar.gz -C /mnt/root |
|||
# create temporary resolv.conf in the new system |
|||
- touch /mnt/root/etc/resolv.conf |
|||
- echo "nameserver 8.8.8.8" > /mnt/root/etc/resolv.conf |
|||
# chroot to /mnt/root and start executing commands one by one |
|||
# update apt's package cache |
|||
- chroot /mnt/root sh -c "apt-get update" |
|||
# install Linux image, which will install kernel and create initrd and all |
|||
# you need to install specific version depending on OS, eg 20.04 will use linux-image-5.4.0-42-generic |
|||
# we also install: init, dbus, iproute2, sudo, which also pull systemd - to have actually usable system |
|||
# additionally install nano to be able to edit confs, you can change that to any other editor |
|||
- chroot /mnt/root sh -c "apt-get install -y linux-image-5.8.0-28-generic initramfs-tools init dbus iproute2 sudo nano --no-install-recommends" |
|||
# I personally always install openssh-server as well, ping for debugging |
|||
# and you may also want to add isc-dhcp-client package to enable networking setup by DHCP server |
|||
- chroot /mnt/root sh -c "apt-get install -y openssh-server isc-dhcp-client iputils-ping --no-install-recommends" |
|||
# add at least one user, here we add user ubuntu with password ubuntu, change it here or later after first login |
|||
- chroot /mnt/root sh -c "useradd -m ubuntu -s '/bin/bash' && echo ubuntu:ubuntu | chpasswd" |
|||
# add this new user to correct groups to enable it to be admin and to have sudo access |
|||
- chroot /mnt/root sh -c "addgroup ubuntu adm" |
|||
- chroot /mnt/root sh -c "addgroup ubuntu sudo" |
|||
# this would installs Xubuntu ... or switch to whatever you need... if you install some other package or desktop environment - it will be there after your login |
|||
# but it is quite large (2GB) so if ANY package fails or throws ANY error - whole subiquity installer crashes; so I recommend this to be done on first interactive login after reboot |
|||
# - chroot /mnt/root sh -c "apt-get install -y xubuntu-core" |
|||
# below is syslinux install the easy way, through Ubuntu's official package/repo |
|||
# get the syslinux package, note this is not in chroot, this installs just to subiquity memory, so we need to run apt update again |
|||
- apt-get update |
|||
- apt-get install -y syslinux |
|||
# tell syslinux to install itself to your sda1 which is your boot partition |
|||
# if you mounted it earlier, unmount boot!! use command below (which is commented out by default) |
|||
# - umount /mnt/boot |
|||
- syslinux -i /dev/sda1 |
|||
# now that syslinux is installed, burn it's mbr.bin (or maybe gptmbr.bin if you plan to use GPT + UEFI) to start of your disk; note we target whole device "sda" - NOT sda1 |
|||
- dd if=/usr/lib/syslinux/mbr/mbr.bin of=/dev/sda bs=440 count=1 conv=notrunc |
|||
# now we can safely mount boot partition |
|||
- mount /dev/sda1 /mnt/boot |
|||
# we create syslinux.cfg, I do touch, as if it doesn't exist it will break subiquity again |
|||
- touch /mnt/boot/syslinux.cfg |
|||
# echo your config to it; explaining |
|||
# PROMPT 0 - don't ask use default / 1 - ask for user input (good for diag); DEFAULT - set which label is default so syslinux can autoboot; LABEL - this is config for our Ubuntu Base OS; KERNEL - vmlinuz or eqivalent kernel name; APPEND - to mount your /root partiton as writeable; INITRD - name of your initrd image |
|||
- (echo PROMPT 0; echo DEFAULT base; echo LABEL base; echo KERNEL vmlinuz; echo APPEND root=/dev/sda2 rw; echo INITRD initrd.img) > /mnt/boot/syslinux.cfg |
|||
# copy vmlinuz & initrd files that you've installed in your chroot, you can specify exact version, just make sure to change syslinux.cfg echo (above) accordingly |
|||
# can also copy * to copy all, but all we need is these ones really |
|||
- cp /mnt/root/boot/vmlinuz /mnt/boot |
|||
- cp /mnt/root/boot/initrd.img /mnt/boot |
|||
# setup EFI boot, you can keep both BIOS and UEFI bootloaders at the same time |
|||
# install additional package |
|||
- apt-get install -y syslinux-efi |
|||
# create directories, will create both BOOT and parent EFI folders |
|||
- mkdir -p /mnt/boot/EFI/BOOT/ |
|||
# copy all files, in order: UEFI bootloader, bootloader's module (required), syslinux config (same as above), kernel and initrd (same as above) |
|||
- cp /usr/lib/SYSLINUX.EFI/efi64/syslinux.efi /mnt/boot/EFI/BOOT/BOOTX64.EFI |
|||
- cp /usr/lib/syslinux/modules/efi64/ldlinux.e64 /mnt/boot/EFI/BOOT/ |
|||
- cp /mnt/boot/syslinux.cfg /mnt/boot/EFI/BOOT/syslinux.cfg |
|||
- cp /mnt/root/boot/vmlinuz /mnt/boot/EFI/BOOT/ |
|||
- cp /mnt/root/boot/initrd.img /mnt/boot/EFI/BOOT/ |
|||
# now we create network config, make sure to change: interface name, IP, gateway |
|||
- touch /mnt/root/etc/systemd/network/00-wired.network |
|||
- (echo [Match]; echo Name=enp0s10f0; echo [Network]; echo Address=10.10.2.101/24; echo Gateway=10.10.2.99; echo DNS=8.8.8.8) > /mnt/root/etc/systemd/network/00-wired.network |
|||
# and enable networkd service so it runs on first boot already |
|||
- chroot /mnt/root sh -c "systemctl enable systemd-networkd.service" |
|||
# this is optional, but cleans 100+MB from our chroot partition |
|||
- chroot /mnt/root sh -c "apt-get clean" |
|||
# and finally, I leave this uncommented sometimes, to allow me to do anything in interactive bash shell before final reboot (or to just pause and wait for you if you took coffee and don't want your system to reboot unattended) |
|||
# - bash -c "exec bash" |
|||
# unmount partitions |
|||
- umount /mnt/boot |
|||
- umount /mnt/root |
|||
# and reboot! |
|||
- reboot |
|||
# after reboot login with your user (ubuntu/ubuntu in this script) and complete installation and/or configuration |
|||
# you can also connect using ssh to this machine, sudo, and install or configure whatever you wish! Congrats! |
@ -0,0 +1 @@ |
|||
minios |
@ -0,0 +1,7 @@ |
|||
127.0.0.1 localhost |
|||
127.0.1.1 minios |
|||
|
|||
# The following lines are desirable for IPv6 capable hosts |
|||
::1 localhost ip6-localhost ip6-loopback |
|||
ff02::1 ip6-allnodes |
|||
ff02::2 ip6-allrouters |
@ -0,0 +1,2 @@ |
|||
Welcome to MiniOS! \n \l |
|||
|
@ -0,0 +1 @@ |
|||
MiniOS 2021 |
@ -0,0 +1,122 @@ |
|||
# $OpenBSD: sshd_config,v 1.101 2017/03/14 07:19:07 djm Exp $ |
|||
|
|||
# This is the sshd server system-wide configuration file. See |
|||
# sshd_config(5) for more information. |
|||
|
|||
# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin |
|||
|
|||
# The strategy used for options in the default sshd_config shipped with |
|||
# OpenSSH is to specify options with their default value where |
|||
# possible, but leave them commented. Uncommented options override the |
|||
# default value. |
|||
|
|||
#Port 22 |
|||
#AddressFamily any |
|||
#ListenAddress 0.0.0.0 |
|||
#ListenAddress :: |
|||
|
|||
#HostKey /etc/ssh/ssh_host_rsa_key |
|||
#HostKey /etc/ssh/ssh_host_ecdsa_key |
|||
#HostKey /etc/ssh/ssh_host_ed25519_key |
|||
|
|||
# Ciphers and keying |
|||
#RekeyLimit default none |
|||
|
|||
# Logging |
|||
#SyslogFacility AUTH |
|||
#LogLevel INFO |
|||
|
|||
# Authentication: |
|||
|
|||
#LoginGraceTime 2m |
|||
PermitRootLogin yes |
|||
#StrictModes yes |
|||
#MaxAuthTries 6 |
|||
#MaxSessions 10 |
|||
|
|||
#PubkeyAuthentication yes |
|||
|
|||
# Expect .ssh/authorized_keys2 to be disregarded by default in future. |
|||
#AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2 |
|||
|
|||
#AuthorizedPrincipalsFile none |
|||
|
|||
#AuthorizedKeysCommand none |
|||
#AuthorizedKeysCommandUser nobody |
|||
|
|||
# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts |
|||
#HostbasedAuthentication no |
|||
# Change to yes if you don't trust ~/.ssh/known_hosts for |
|||
# HostbasedAuthentication |
|||
#IgnoreUserKnownHosts no |
|||
# Don't read the user's ~/.rhosts and ~/.shosts files |
|||
#IgnoreRhosts yes |
|||
|
|||
# To disable tunneled clear text passwords, change to no here! |
|||
PasswordAuthentication yes |
|||
#PermitEmptyPasswords no |
|||
|
|||
# Change to yes to enable challenge-response passwords (beware issues with |
|||
# some PAM modules and threads) |
|||
ChallengeResponseAuthentication no |
|||
|
|||
# Kerberos options |
|||
#KerberosAuthentication no |
|||
#KerberosOrLocalPasswd yes |
|||
#KerberosTicketCleanup yes |
|||
#KerberosGetAFSToken no |
|||
|
|||
# GSSAPI options |
|||
#GSSAPIAuthentication no |
|||
#GSSAPICleanupCredentials yes |
|||
#GSSAPIStrictAcceptorCheck yes |
|||
#GSSAPIKeyExchange no |
|||
|
|||
# Set this to 'yes' to enable PAM authentication, account processing, |
|||
# and session processing. If this is enabled, PAM authentication will |
|||
# be allowed through the ChallengeResponseAuthentication and |
|||
# PasswordAuthentication. Depending on your PAM configuration, |
|||
# PAM authentication via ChallengeResponseAuthentication may bypass |
|||
# the setting of "PermitRootLogin without-password". |
|||
# If you just want the PAM account and session checks to run without |
|||
# PAM authentication, then enable this but set PasswordAuthentication |
|||
# and ChallengeResponseAuthentication to 'no'. |
|||
UsePAM yes |
|||
|
|||
#AllowAgentForwarding yes |
|||
#AllowTcpForwarding yes |
|||
#GatewayPorts no |
|||
X11Forwarding yes |
|||
#X11DisplayOffset 10 |
|||
#X11UseLocalhost yes |
|||
#PermitTTY yes |
|||
PrintMotd no |
|||
#PrintLastLog yes |
|||
#TCPKeepAlive yes |
|||
#UseLogin no |
|||
#PermitUserEnvironment no |
|||
#Compression delayed |
|||
#ClientAliveInterval 0 |
|||
#ClientAliveCountMax 3 |
|||
#UseDNS no |
|||
#PidFile /var/run/sshd.pid |
|||
#MaxStartups 10:30:100 |
|||
#PermitTunnel no |
|||
#ChrootDirectory none |
|||
#VersionAddendum none |
|||
|
|||
# no default banner path |
|||
#Banner none |
|||
|
|||
# Allow client to pass locale environment variables |
|||
AcceptEnv LANG LC_* |
|||
|
|||
# override default of no subsystems |
|||
Subsystem sftp /usr/lib/openssh/sftp-server |
|||
|
|||
# Example of overriding settings on a per-user basis |
|||
#Match User anoncvs |
|||
# X11Forwarding no |
|||
# AllowTcpForwarding no |
|||
# PermitTTY no |
|||
# ForceCommand cvs server |
@ -0,0 +1 @@ |
|||
Europe/Moscow |
@ -0,0 +1,140 @@ |
|||
# ~/.bashrc: executed by bash(1) for non-login shells. |
|||
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) |
|||
# for examples |
|||
|
|||
# If not running interactively, don't do anything |
|||
case $- in |
|||
*i*) ;; |
|||
*) return;; |
|||
esac |
|||
|
|||
# don't put duplicate lines or lines starting with space in the history. |
|||
# See bash(1) for more options |
|||
HISTCONTROL=ignoreboth |
|||
|
|||
# append to the history file, don't overwrite it |
|||
shopt -s histappend |
|||
|
|||
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1) |
|||
HISTSIZE=1000 |
|||
HISTFILESIZE=2000 |
|||
|
|||
# check the window size after each command and, if necessary, |
|||
# update the values of LINES and COLUMNS. |
|||
shopt -s checkwinsize |
|||
|
|||
# If set, the pattern "**" used in a pathname expansion context will |
|||
# match all files and zero or more directories and subdirectories. |
|||
#shopt -s globstar |
|||
|
|||
# make less more friendly for non-text input files, see lesspipe(1) |
|||
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" |
|||
|
|||
# set variable identifying the chroot you work in (used in the prompt below) |
|||
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then |
|||
debian_chroot=$(cat /etc/debian_chroot) |
|||
fi |
|||
|
|||
# set a fancy prompt (non-color, unless we know we "want" color) |
|||
case "$TERM" in |
|||
xterm-color|*-256color) color_prompt=yes;; |
|||
esac |
|||
|
|||
# uncomment for a colored prompt, if the terminal has the capability; turned |
|||
# off by default to not distract the user: the focus in a terminal window |
|||
# should be on the output of commands, not on the prompt |
|||
#force_color_prompt=yes |
|||
|
|||
if [ -n "$force_color_prompt" ]; then |
|||
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then |
|||
# We have color support; assume it's compliant with Ecma-48 |
|||
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such |
|||
# a case would tend to support setf rather than setaf.) |
|||
color_prompt=yes |
|||
else |
|||
color_prompt= |
|||
fi |
|||
fi |
|||
|
|||
if [ "$color_prompt" = yes ]; then |
|||
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' |
|||
else |
|||
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' |
|||
fi |
|||
unset color_prompt force_color_prompt |
|||
|
|||
# If this is an xterm set the title to user@host:dir |
|||
case "$TERM" in |
|||
xterm*|rxvt*) |
|||
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" |
|||
;; |
|||
*) |
|||
;; |
|||
esac |
|||
|
|||
# enable color support of ls and also add handy aliases |
|||
if [ -x /usr/bin/dircolors ]; then |
|||
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" |
|||
alias ls='ls --color=auto' |
|||
#alias dir='dir --color=auto' |
|||
#alias vdir='vdir --color=auto' |
|||
|
|||
alias grep='grep --color=auto' |
|||
alias fgrep='fgrep --color=auto' |
|||
alias egrep='egrep --color=auto' |
|||
fi |
|||
|
|||
# colored GCC warnings and errors |
|||
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' |
|||
|
|||
# some more ls aliases |
|||
alias ll='ls -alF' |
|||
alias la='ls -A' |
|||
alias l='ls -CF' |
|||
|
|||
# Add an "alert" alias for long running commands. Use like so: |
|||
# sleep 10; alert |
|||
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' |
|||
|
|||
# Alias definitions. |
|||
# You may want to put all your additions into a separate file like |
|||
# ~/.bash_aliases, instead of adding them here directly. |
|||
# See /usr/share/doc/bash-doc/examples in the bash-doc package. |
|||
|
|||
if [ -f ~/.bash_aliases ]; then |
|||
. ~/.bash_aliases |
|||
fi |
|||
|
|||
# enable programmable completion features (you don't need to enable |
|||
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile |
|||
# sources /etc/bash.bashrc). |
|||
if ! shopt -oq posix; then |
|||
if [ -f /usr/share/bash-completion/bash_completion ]; then |
|||
. /usr/share/bash-completion/bash_completion |
|||
elif [ -f /etc/bash_completion ]; then |
|||
. /etc/bash_completion |
|||
fi |
|||
fi |
|||
|
|||
apt-get() |
|||
{ |
|||
if [ -e /var/cache/apt/pkgcache.bin ]; then |
|||
/usr/bin/apt-get "$@" |
|||
else |
|||
/usr/bin/apt-get update |
|||
/usr/bin/apt-get "$@" |
|||
fi |
|||
} |
|||
|
|||
apt() |
|||
{ |
|||
if [ -e /var/cache/apt/pkgcache.bin ]; then |
|||
/usr/bin/apt "$@" |
|||
else |
|||
/usr/bin/apt update |
|||
/usr/bin/apt "$@" |
|||
fi |
|||
} |
|||
|
|||
export -f apt-get |
|||
export -f apt |
@ -0,0 +1,58 @@ |
|||
#!/bin/bash |
|||
# Author: Tomas M. <http://www.slax.org/> |
|||
|
|||
usage() |
|||
{ |
|||
echo "" |
|||
echo "Convert directory to .sb compressed module" |
|||
echo "Usage: $0 [source_directory.sb] [[target_file.sb]]" |
|||
echo " If source_directory does not have .sb suffix and it is not 'squashfs-root'," |
|||
echo " then the source_directory itself is included in the module and" |
|||
echo " then the target_file.sb parameter is required." |
|||
echo " If target_file.sb is not specified, the source_directory is erased" |
|||
echo " and replaced by the newly generated module file." |
|||
} |
|||
|
|||
P1="$(readlink -f "$1")" |
|||
P2="$(readlink -f "$2")" |
|||
|
|||
if [ "$P1" = "$P2" ]; then |
|||
P2="" |
|||
fi |
|||
|
|||
SB=$(echo "$P1" | grep -o "[.]sb/*\$") |
|||
if [ "$(echo "$P1" | grep -o "/squashfs-root/*\$")" != "" ]; then |
|||
SB="true" |
|||
fi |
|||
|
|||
if [ "$SB" = "" ]; then |
|||
KEEP="-keep-as-directory" |
|||
if [ "$P2" = "" ]; then |
|||
usage |
|||
exit 1 |
|||
fi |
|||
else |
|||
KEEP="" |
|||
fi |
|||
|
|||
if [ ! -d "$P1" ]; then |
|||
echo "Not a directory: $P1" >&2 |
|||
exit 2 |
|||
fi |
|||
|
|||
|
|||
if [ "$P2" = "" ]; then |
|||
TARGET="$P1".sb |
|||
while [ -e "$TARGET" ]; do TARGET="$TARGET"x; done |
|||
mksquashfs "$P1" "$TARGET" -comp xz -b 1024K -always-use-fragments $KEEP >/dev/null || exit 3 |
|||
umount "$P1" 2>/dev/null |
|||
rm -Rf "$P1" |
|||
mv "$TARGET" "$P1" |
|||
else |
|||
if [ -e "$P2" ]; then |
|||
echo "Target exists: $P2" >&2 |
|||
exit 4 |
|||
fi |
|||
|
|||
mksquashfs "$P1" "$P2" -comp xz -b 1024K -always-use-fragments $KEEP >/dev/null |
|||
fi |
@ -0,0 +1,48 @@ |
|||
#!/bin/bash |
|||
|
|||
. /run/initramfs/lib/config || exit 1 |
|||
|
|||
TMP=/tmp/changes$$ |
|||
EXCLUDE="^\$|/\$|[.]wh[.][.]wh[.]orph/|^[.]wh[.][.]wh[.]plnk/|^[.]wh[.][.]wh[.]aufs|^var/cache/|^var/backups/|^var/tmp/|^var/log/|^var/lib/apt/|^var/lib/dhcp/|^var/lib/systemd/|^sbin/fsck[.]aufs|^etc/resolv[.]conf|^root/[.]Xauthority|^root/[.]xsession-errors|^root/[.]fehbg|^root/[.]fluxbox/lastwallpaper|^root/[.]fluxbox/menu_resolution|^etc/mtab|^etc/fstab|^boot/|^dev/|^mnt/|^proc/|^run/|^sys/|^tmp/" |
|||
CHANGES=/run/initramfs/memory/changes |
|||
|
|||
if [ "$1" = "" ]; then |
|||
echo "" |
|||
echo "savechanges - save all changed files in a compressed filesystem bundle" |
|||
echo " - excluding some predefined files such as /etc/mtab," |
|||
echo " temp & log files, empty directories, apt cache, and such" |
|||
echo "" |
|||
echo "Usage:" |
|||
echo " $0 [ target_file.sb ] [ changes_directory ]" |
|||
echo "" |
|||
echo "If changes_directory is not specified, /run/initramfs/memory/changes is used." |
|||
echo "" |
|||
exit 1 |
|||
fi |
|||
|
|||
if [ ! "$2" = "" ]; then |
|||
CHANGES="$2" |
|||
fi |
|||
|
|||
# exclude the save_file itself of course |
|||
EXCLUDE="$EXCLUDE|^""$(readlink -f "$1" | cut -b 2- | sed -r "s/[.]/[.]/")""\$" |
|||
|
|||
CWD=$(pwd) |
|||
|
|||
cd $CHANGES || exit |
|||
|
|||
mkdir -p $TMP |
|||
mount -t tmpfs tmpfs $TMP |
|||
|
|||
find \( -type d -printf "%p/\n" , -not -type d -print \) \ |
|||
| sed -r "s/^[.]\\///" | egrep -v "$EXCLUDE" \ |
|||
| while read FILE; do |
|||
cp --parents -afr "$FILE" "$TMP" |
|||
done |
|||
|
|||
cd $CWD |
|||
|
|||
mksquashfs $TMP "$1" -comp $COMP_TYPE -b 1024K -always-use-fragments -noappend |
|||
|
|||
umount $TMP |
|||
rmdir $TMP |
@ -0,0 +1,86 @@ |
|||
#!/bin/bash |
|||
# Rebuild initial ramdisk with full network drivers, |
|||
# start DHCP and TFTP server in order to provide PXE service |
|||
# |
|||
# Author: Tomas M <www.slax.org> |
|||
|
|||
LIVE=/run/initramfs |
|||
FTPROOT=/var/state/dnsmasq/root |
|||
|
|||
# find out our own IP address. If more interfaces are available, use the first one |
|||
IP="$(hostname -I | cut -d " " -f 1)" |
|||
GW=$(ip route show | grep default | grep -o "via.*" | head -n 1 | cut -d " " -f 2) |
|||
|
|||
# if no IP is assigned to this computer, setup private address randomly |
|||
if [ "$IP" = "" ]; then |
|||
killall dhclient 2>/dev/null |
|||
IP="10."$(($RANDOM/130+1))"."$(($RANDOM/130+1))".1" |
|||
ifconfig $(ls -1 /sys/class/net | egrep -v '^lo$' | sort | head -n 1) $IP netmask 255.255.255.0 |
|||
fi |
|||
|
|||
# if gateway is not recognized, lets make our IP a gateway and enable forwarding |
|||
if [ "$GW" = "" ]; then |
|||
GW="$IP" |
|||
echo 1 > /proc/sys/net/ipv4/conf/all/forwarding |
|||
echo 1 > /proc/sys/net/ipv6/conf/all/forwarding |
|||
fi |
|||
|
|||
echo Starting PXE server on $IP ... |
|||
|
|||
# calculate C class range |
|||
RANGE=$(echo $IP | cut -d "." -f 1-3) |
|||
|
|||
# make sure dnsmasq can be started |
|||
killall dnsmasq 2>/dev/null |
|||
killall busybox 2>/dev/null |
|||
rm -Rf $FTPROOT 2>/dev/null |
|||
mkdir -p $FTPROOT/{pxelinux.cfg,tmp}/ |
|||
|
|||
# create root filesystem for ftfp |
|||
cd $LIVE |
|||
( find . -print | grep -v "memory" |
|||
cd / |
|||
find /lib/modules/$(uname -r)/kernel/drivers/net | grep -v wireless |
|||
) | cpio -pvd $FTPROOT/tmp 2>/dev/null |
|||
|
|||
cp /lib/modules/$(uname -r)/modules.* $FTPROOT/tmp/lib/modules/$(uname -r) |
|||
depmod -b $FTPROOT/tmp |
|||
rm $FTPROOT/tmp/lib/initramfs_escaped |
|||
|
|||
# pack root in initramfs |
|||
cd $FTPROOT/tmp |
|||
find . -print | cpio -o -H newc 2>/dev/null | gzip -f --fast >../initrfs.img |
|||
cd .. |
|||
rm -Rf tmp |
|||
|
|||
# link files here since copying is not necessary |
|||
ln -s $(find $LIVE/memory/{data,iso,toram} 2>/dev/null | grep vmlinuz | head -n 1) $FTPROOT/vmlinuz |
|||
ln -s $(find $LIVE/memory/{data,iso,toram} 2>/dev/null | grep pxelinux.0 | head -n 1) $FTPROOT/pxelinux.0 |
|||
ln -s $(find $LIVE/memory/{data,iso,toram} 2>/dev/null | grep ldlinux.c32 | head -n 1) $FTPROOT/ldlinux.c32 |
|||
|
|||
find $LIVE/memory/{data,iso,toram} 2>/dev/null | egrep "[.]sb\$" | sort -n | while read LINE; do |
|||
BAS="$(basename "$LINE")" |
|||
ln -s $LINE "$FTPROOT/$BAS" |
|||
echo $BAS >> "$FTPROOT/PXEFILELIST" |
|||
done |
|||
|
|||
echo "This is <a href=http://www.slax.org/>Slax</a> PXE data server. PXE clients will download <a href=PXEFILELIST>file list</a>" > "$FTPROOT/index.html" |
|||
|
|||
# default pxelinux configuration. Keep xmode selection for clients the same like for the server |
|||
echo " |
|||
PROMPT 0 |
|||
DEFAULT slax |
|||
LABEL slax |
|||
KERNEL /vmlinuz |
|||
IPAPPEND 1 |
|||
APPEND initrd=/initrfs.img load_ramdisk=1 prompt_ramdisk=0 rw printk.time=0 $(cat /proc/cmdline | egrep -o 'slax.flags=[^ ]+' | sed -r 's:[,=]pxe::' | sed -r 's:[,=]toram::') |
|||
" > $FTPROOT/pxelinux.cfg/default |
|||
|
|||
# start the DHCP server and TFTP server |
|||
dnsmasq --enable-tftp --tftp-root=/var/state/dnsmasq/root \ |
|||
--dhcp-boot=pxelinux.0,"$IP",$IP \ |
|||
--dhcp-option=3,$GW \ |
|||
--dhcp-range=$RANGE.2,$RANGE.250,infinite --log-dhcp |
|||
|
|||
# start HTTP server at port 7529 (that are the numbers you type on your phone to write 'slax') |
|||
busybox httpd -p 7529 -h /var/state/dnsmasq/root |
@ -0,0 +1,17 @@ |
|||
#!/bin/bash |
|||
# Author: Tomas M. <http://www.slax.org/> |
|||
|
|||
if [ ! -e "$1" ]; then |
|||
echo |
|||
echo "Erase module directory created by sb2dir" |
|||
echo "Usage: $0 [source_directory.sb]" |
|||
exit 1 |
|||
fi |
|||
|
|||
if [ ! -d "$1" ]; then |
|||
echo "Directory does not exist: $1" >&2 |
|||
exit |
|||
fi |
|||
|
|||
umount "$1" 2>/dev/null |
|||
rm -Rf "$1" |
@ -0,0 +1,46 @@ |
|||
#!/bin/bash |
|||
|
|||
TMP=/tmp/changes$$ |
|||
EXCLUDE="^\$|/\$|[.]wh[.][.]wh[.]orph/|^[.]wh[.][.]wh[.]plnk/|^[.]wh[.][.]wh[.]aufs|^var/cache/|^var/backups/|^var/tmp/|^var/log/|^var/lib/apt/|^var/lib/dhcp/|^var/lib/systemd/|^sbin/fsck[.]aufs|^etc/resolv[.]conf|^root/[.]Xauthority|^root/[.]xsession-errors|^root/[.]fehbg|^root/[.]fluxbox/lastwallpaper|^root/[.]fluxbox/menu_resolution|^etc/mtab|^etc/fstab|^boot/|^dev/|^mnt/|^proc/|^run/|^sys/|^tmp/" |
|||
CHANGES=/run/initramfs/memory/changes |
|||
|
|||
if [ "$1" = "" ]; then |
|||
echo "" |
|||
echo "savechanges - save all changed files in a compressed filesystem bundle" |
|||
echo " - excluding some predefined files such as /etc/mtab," |
|||
echo " temp & log files, empty directories, apt cache, and such" |
|||
echo "" |
|||
echo "Usage:" |
|||
echo " $0 [ target_file.sb ] [ changes_directory ]" |
|||
echo "" |
|||
echo "If changes_directory is not specified, /run/initramfs/memory/changes is used." |
|||
echo "" |
|||
exit 1 |
|||
fi |
|||
|
|||
if [ ! "$2" = "" ]; then |
|||
CHANGES="$2" |
|||
fi |
|||
|
|||
# exclude the save_file itself of course |
|||
EXCLUDE="$EXCLUDE|^""$(readlink -f "$1" | cut -b 2- | sed -r "s/[.]/[.]/")""\$" |
|||
|
|||
CWD=$(pwd) |
|||
|
|||
cd $CHANGES || exit |
|||
|
|||
mkdir -p $TMP |
|||
mount -t tmpfs tmpfs $TMP |
|||
|
|||
find \( -type d -printf "%p/\n" , -not -type d -print \) \ |
|||
| sed -r "s/^[.]\\///" | egrep -v "$EXCLUDE" \ |
|||
| while read FILE; do |
|||
cp --parents -afr "$FILE" "$TMP" |
|||
done |
|||
|
|||
cd $CWD |
|||
|
|||
mksquashfs $TMP "$1" -comp xz -b 1024K -always-use-fragments -noappend |
|||
|
|||
umount $TMP |
|||
rmdir $TMP |
@ -0,0 +1,29 @@ |
|||
#!/bin/bash |
|||
|
|||
if [ "$1" = "rm" ]; then |
|||
shift |
|||
rmsbdir "$@" |
|||
exit $? |
|||
fi |
|||
|
|||
if [ "$1" = "rmdir" ]; then |
|||
shift |
|||
rmsbdir "$@" |
|||
exit $? |
|||
fi |
|||
|
|||
if [ "$1" = "conv" ]; then |
|||
shift |
|||
fi |
|||
|
|||
if [ ! -r "$1" ]; then |
|||
echo File not found "$1" |
|||
exit 1 |
|||
fi |
|||
|
|||
if [ -d "$1" ]; then |
|||
dir2sb "$@" |
|||
exit $? |
|||
fi |
|||
|
|||
sb2dir "$@" |
@ -0,0 +1,33 @@ |
|||
#!/bin/bash |
|||
# Author: Tomas M. <http://www.slax.org/> |
|||
|
|||
if [ ! -e "$1" ]; then |
|||
echo |
|||
echo "Convert .sb compressed module into directory with the same name" |
|||
echo "Usage: $0 [source_file.sb] [[optional output_directory]]" |
|||
echo " If the output_directory is specified, it must exist" |
|||
echo " If the output_directory is not specified, the name source_file.sb" |
|||
echo " is used and the directory is overmounted with tmpfs" |
|||
exit 1 |
|||
fi |
|||
|
|||
if [ ! -r "$1" ]; then |
|||
echo "File does not exist: $1" >&2 |
|||
exit |
|||
fi |
|||
|
|||
if [ "$2" = "" ]; then |
|||
SOURCE="$1".x |
|||
while [ -e "$SOURCE" ]; do SOURCE="$SOURCE"x; done |
|||
mv "$1" "$SOURCE" || exit |
|||
mkdir "$1" |
|||
mount -t tmpfs tmpfs "$1" |
|||
unsquashfs -f -dest "$1" "$SOURCE" >/dev/null || exit |
|||
rm "$SOURCE" |
|||
else |
|||
if [ ! -d "$2" ]; then |
|||
echo "Directory does not exist: $2" >&2 |
|||
exit |
|||
fi |
|||
unsquashfs -f -dest "$2" "$1" >/dev/null |
|||
fi |
@ -0,0 +1,178 @@ |
|||
#!/bin/bash |
|||
# Slax management and control script |
|||
# Author: Tomas M <http://www.slax.org/> |
|||
|
|||
# activate |
|||
# deactivate |
|||
# list |
|||
|
|||
|
|||
LIVE=/run/initramfs/memory |
|||
RAMSTORE=$LIVE/modules |
|||
|
|||
# Print error message and exit |
|||
# $1 = error message |
|||
# |
|||
die() |
|||
{ |
|||
echo "$1" >&2 |
|||
exit 1 |
|||
} |
|||
|
|||
|
|||
print_branches() |
|||
{ |
|||
local SI BUNDLE LOOP CWD |
|||
|
|||
SI="/sys/fs/aufs/$(cat /proc/mounts | grep 'aufs / aufs' | egrep -o 'si=([^,) ]+)' | tr = _)" |
|||
CWD="$(pwd)" |
|||
cd "$SI" |
|||
ls -v1 | grep -v xi_path | egrep 'br[0-9]+' | xargs cat | grep memory/bundles | rev | cut -b 4- | rev | while read BUNDLE; do |
|||
if mountpoint -q "$BUNDLE"; then |
|||
LOOP=$(cat /proc/mounts | fgrep " $BUNDLE squashfs" | cut -d " " -f 1) |
|||
echo -n "$BUNDLE" |
|||
echo -ne "\t" |
|||
losetup $LOOP | sed -r "s:.*[(]|[)].*::g" |
|||
fi |
|||
done | tac |
|||
cd "$CWD" |
|||
} |
|||
|
|||
|
|||
# Activate Slax Bundle |
|||
# $1 = file to activate |
|||
# |
|||
activate() |
|||
{ |
|||
local SB TGT BAS |
|||
|
|||
SB="$(readlink -f "$1")" |
|||
BAS="$(basename "$SB")" |
|||
|
|||
# check if file exists |
|||
if [ ! -r "$SB" ]; then |
|||
usage |
|||
die "file not found $SB" |
|||
fi |
|||
|
|||
# check if the file is part of aufs union, if yes we need to copy it outside |
|||
if df "$SB" | cut -d " " -f 1 | grep -q aufs; then |
|||
TGT="$RAMSTORE" |
|||
mkdir -p "$TGT" |
|||
if [ -r $TGT/$BAS ]; then die "File exists: $TGT/$BAS"; fi |
|||
cp -n "$SB" "$TGT/$BAS" |
|||
if [ $? -ne 0 ]; then die "Error copying file to $TGT/$BAS. Not enough free RAM or disk space?"; fi |
|||
SB="$TGT/$BAS" |
|||
fi |
|||
|
|||
# check if this particular file is already activated |
|||
if print_branches | cut -f 2 | fgrep -q "$SB"; then |
|||
exit |
|||
fi |
|||
|
|||
# mount remount,add |
|||
TGT="$LIVE/bundles/$BAS" |
|||
mkdir -p "$TGT" |
|||
|
|||
mount -n -o loop,ro "$SB" "$TGT" |
|||
if [ $? -ne 0 ]; then |
|||
die "Error mounting $SB to $TGT, perhaps corrupted download" |
|||
fi |
|||
|
|||
# add current branch to aufs union |
|||
mount -t aufs -o remount,add:1:"$TGT" aufs / |
|||
if [ $? -ne 0 ]; then |
|||
umount "$TGT" |
|||
rmdir "$TGT" |
|||
die "Error attaching bundle filesystem to Slax" |
|||
fi |
|||
|
|||
echo "Slax Bundle activated: $BAS" |
|||
} |
|||
|
|||
|
|||
# Deactivate Slax bundle of the given name |
|||
# $1 = path to bundle file, or its name |
|||
# |
|||
deactivate() |
|||
{ |
|||
local BUNDLES SB MATCH LOOP LOOPFILE |
|||
|
|||
BUNDLES=$LIVE/bundles |
|||
MODULES=$LIVE/modules |
|||
SB="$(basename "$1")" |
|||
|
|||
rmdir "$BUNDLES/$SB" 2>/dev/null # this fails unless the dir is |
|||
rmdir "$BUNDLES/$SB.sb" 2>/dev/null # forgotten there empty. It's safe this way |
|||
|
|||
if [ ! -d "$BUNDLES/$SB" ]; then |
|||
# we don't have real filename match, lets try to add .sb extension |
|||
if [ ! -d "$BUNDLES/$SB.sb" ]; then |
|||
# no, still no match. Lets use some guesswork |
|||
SB=$(print_branches | cut -f 2 | egrep -o "/[0-9]+-$SB.sb\$" | tail -n 1 | xargs -r basename) |
|||
else |
|||
SB="$SB.sb" |
|||
fi |
|||
fi |
|||
|
|||
if [ "$SB" = "" -o ! -d "$BUNDLES/$SB" ]; then |
|||
die "can't find active slax bundle $1" |
|||
fi |
|||
|
|||
echo "Attempting to deactivate Slax bundle $SB..." |
|||
mount -t aufs -o remount,verbose,del:"$BUNDLES/$SB" aufs / 2>/dev/null |
|||
if [ $? -ne 0 ]; then |
|||
die "Unable to deactivate Slax Bundle - still in use. See dmesg for more." |
|||
fi |
|||
|
|||
# remember what loop device was the bundle mounted to, it may be needed later |
|||
LOOP="$(cat /proc/mounts | fgrep " $BUNDLES/$SB " | cut -d " " -f 1)" |
|||
LOOPFILE="$(losetup "$LOOP" | cut -d " " -f 3 | sed -r 's:^.|.$::g')" |
|||
|
|||
umount "$BUNDLES/$SB" 2>/dev/null |
|||
if [ $? -ne 0 ]; then |
|||
die "Unable to umount Slax bundle loop-mount $BUNDLES/$SB" |
|||
fi |
|||
rmdir "$BUNDLES/$SB" |
|||
|
|||
# free the loop device manually since umount fails to do that if the bundle was activated on boot |
|||
losetup -d "$LOOP" 2>/dev/null |
|||
|
|||
if echo "$LOOPFILE" | grep -q $RAMSTORE; then |
|||
rm -f $LOOPFILE |
|||
fi |
|||
|
|||
echo "Slax Bundle deactivated: $SB" |
|||
} |
|||
|
|||
|
|||
usage() |
|||
{ |
|||
echo "Usage: $0 [ activate | deactivate | list ] [ file.sb ]" >&2 |
|||
if [ "$1" != "" ]; then |
|||
echo "$1" >&2 |
|||
fi |
|||
} |
|||
|
|||
|
|||
if [ "$1" = "" ]; then |
|||
usage |
|||
die |
|||
fi |
|||
|
|||
if [ "$1" = "activate" ]; then |
|||
activate "$2" |
|||
fi |
|||
|
|||
if [ "$1" = "deactivate" ]; then |
|||
deactivate "$2" |
|||
fi |
|||
|
|||
if [ "$1" = "list" ]; then |
|||
print_branches |
|||
fi |
|||
|
|||
if [ "$1" = "savechanges" ]; then |
|||
shift |
|||
savechanges "$@" |
|||
fi |
@ -0,0 +1,38 @@ |
|||
[Unit] |
|||
Description=Load AppArmor profiles |
|||
DefaultDependencies=no |
|||
Before=sysinit.target |
|||
After=local-fs.target |
|||
After=systemd-journald-audit.socket |
|||
RequiresMountsFor=/var/cache/apparmor |
|||
AssertPathIsReadWrite=/sys/kernel/security/apparmor/.load |
|||
ConditionSecurity=apparmor |
|||
Documentation=man:apparmor(7) |
|||
Documentation=https://gitlab.com/apparmor/apparmor/wikis/home/ |
|||
|
|||
# Don't start this unit on the Ubuntu Live CD |
|||
ConditionPathExists=!/rofs/etc/apparmor.d |
|||
|
|||
# Don't start this unit on the Debian Live CD when using overlayfs |
|||
ConditionPathExists=!/run/live/overlay/work |
|||
|
|||
# Don't start this unit on Slax Live CD |
|||
ConditionPathExists=!/run/initramfs/lib/livekitlib |
|||
|
|||
[Service] |
|||
Type=oneshot |
|||
ExecStart=/lib/apparmor/apparmor.systemd reload |
|||
ExecReload=/lib/apparmor/apparmor.systemd reload |
|||
|
|||
# systemd maps 'restart' to 'stop; start' which means removing AppArmor confinement |
|||
# from running processes (and not being able to re-apply it later). |
|||
# Upstream systemd developers refused to implement an option that allows overriding |
|||
# this behaviour, therefore we have to make ExecStop a no-op to error out on the |
|||
# safe side. |
|||
# |
|||
# If you really want to unload all AppArmor profiles, run aa-teardown |
|||
ExecStop=/bin/true |
|||
RemainAfterExit=yes |
|||
|
|||
[Install] |
|||
WantedBy=sysinit.target |
@ -0,0 +1,16 @@ |
|||
[Unit] |
|||
Description=DHCP Client |
|||
Documentation=man:dhclient(8) |
|||
Wants=network.target |
|||
After=network-pre.target systemd-sysctl.service systemd-modules-load.service |
|||
Before=network.target shutdown.target network-online.target |
|||
ConditionPathExists=!/run/initramfs/net.up.flag |
|||
|
|||
[Service] |
|||
Type=forking |
|||
ExecStart=-/bin/sh -c 'udevadm settle && dhclient -nw' |
|||
PIDFile=/run/dhclient.pid |
|||
|
|||
[Install] |
|||
WantedBy=multi-user.target |
|||
WantedBy=network-online.target |
@ -0,0 +1,54 @@ |
|||
# 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. |
|||
|
|||
[Unit] |
|||
Description=Getty on %I |
|||
Documentation=man:agetty(8) man:systemd-getty-generator(8) |
|||
Documentation=http://0pointer.de/blog/projects/serial-console.html |
|||
After=systemd-user-sessions.service plymouth-quit-wait.service |
|||
After=rc-local.service |
|||
|
|||
# If additional gettys are spawned during boot then we should make |
|||
# sure that this is synchronized before getty.target, even though |
|||
# getty.target didn't actually pull it in. |
|||
Before=getty.target |
|||
IgnoreOnIsolate=yes |
|||
|
|||
# IgnoreOnIsolate causes issues with sulogin, if someone isolates |
|||
# rescue.target or starts rescue.service from multi-user.target or |
|||
# graphical.target. |
|||
Conflicts=rescue.service |
|||
Before=rescue.service |
|||
|
|||
# On systems without virtual consoles, don't start any getty. Note |
|||
# that serial gettys are covered by serial-getty@.service, not this |
|||
# unit. |
|||
ConditionPathExists=/dev/tty0 |
|||
|
|||
[Service] |
|||
# the VT is cleared by TTYVTDisallocate |
|||
ExecStart=-/sbin/agetty --noclear %I $TERM |
|||
Type=idle |
|||
Restart=always |
|||
RestartSec=0 |
|||
UtmpIdentifier=%I |
|||
TTYPath=/dev/%I |
|||
TTYReset=yes |
|||
TTYVHangup=yes |
|||
#TM do not clear VT: |
|||
TTYVTDisallocate=no |
|||
KillMode=process |
|||
IgnoreSIGPIPE=no |
|||
SendSIGHUP=yes |
|||
|
|||
# Unset locale for the console getty since the console has problems |
|||
# displaying some internationalized messages. |
|||
Environment=LANG= LANGUAGE= LC_CTYPE= LC_NUMERIC= LC_TIME= LC_COLLATE= LC_MONETARY= LC_MESSAGES= LC_PAPER= LC_NAME= LC_ADDRESS= LC_TELEPHONE= LC_MEASUREMENT= LC_IDENTIFICATION= |
|||
|
|||
[Install] |
|||
WantedBy=getty.target |
|||
DefaultInstance=tty1 |
@ -0,0 +1,2 @@ |
|||
# we don't care about loop* and ram* devices |
|||
KERNEL=="[!lr]*", SUBSYSTEM=="block", RUN+="/sbin/slax-automount %r/%k" |
@ -0,0 +1,23 @@ |
|||
#!/bin/bash |
|||
|
|||
LOCK=/run/lock/gtk-bookmark-update-lock |
|||
BOOKMARKS=/root/.gtk-bookmarks |
|||
|
|||
# make sure to avoid parallel execution by using mkdir as lock |
|||
while true; do |
|||
mkdir $LOCK 2>/dev/null |
|||
if [ $? = 0 ]; then |
|||
break |
|||
fi |
|||
done |
|||
|
|||
cat $BOOKMARKS | fgrep -v ///media/ | fgrep -v "file:/// /" | egrep -v '^$' > $BOOKMARKS.tmp 2>/dev/null |
|||
ls -1 /media | sort | while read LINE; do |
|||
echo "file:///media/$LINE $LINE" >> $BOOKMARKS.tmp |
|||
done |
|||
|
|||
echo "file:/// /" >> $BOOKMARKS.tmp # add root at the beginning |
|||
|
|||
mv -f $BOOKMARKS.tmp $BOOKMARKS |
|||
|
|||
rmdir $LOCK |
@ -0,0 +1,67 @@ |
|||
#!/bin/bash |
|||
# Recreate fstab entries in /etc/fstab and make /media directories |
|||
# This script is called by udev rules, see /lib/udev/rules.d/ |
|||
# |
|||
# Author: Tomas M <http://slax.linux-live.org/> |
|||
|
|||
# Variables available in udev environment: |
|||
# $ACTION (eg: add, remove) |
|||
# $DEVNAME (full device node name including path) |
|||
# $DEVTYPE (eg: disk) |
|||
# $ID_FS_TYPE (eg: ext3) |
|||
# $MAJOR and $MINOR numbers |
|||
# $SUBSYSTEM (eg: block) |
|||
|
|||
PATH=$PATH:/usr/bin:/usr/sbin:/bin:/sbin |
|||
|
|||
BAS="$(basename "$DEVNAME")" |
|||
UNIT="media-$BAS.mount" |
|||
MNT="/media/$BAS" |
|||
TARGET="/etc/systemd/system/$UNIT" |
|||
|
|||
|
|||
# exit if noautomount boot parameter is present |
|||
if cat /proc/cmdline | grep -q noautomount; then |
|||
exit |
|||
fi |
|||
|
|||
# exit if 'automount' boot parameter is missing |
|||
if ! cat /proc/cmdline | grep -q automount; then |
|||
exit |
|||
fi |
|||
|
|||
|
|||
if [ "$ACTION" = "add" -o "$ACTION" = "change" ]; then |
|||
if [ ! -r "$TARGET" ]; then # skip if exists |
|||
|
|||
if [ "$ID_FS_TYPE" != "" -a "$(cat /proc/filesystems | grep "$ID_FS_TYPE")" != "" ]; then |
|||
|
|||
mkdir -p "$MNT" |
|||
|
|||
echo "[Unit]" >$TARGET |
|||
echo "Description=Disk $BAS" >>$TARGET |
|||
echo "" >>$TARGET |
|||
echo "[Mount]" >>$TARGET |
|||
echo "What=$DEVNAME" >>$TARGET |
|||
echo "Where=$MNT" >>$TARGET |
|||
echo "Type=$ID_FS_TYPE" >>$TARGET |
|||
echo "Options=defaults" >>$TARGET |
|||
echo "" >>$TARGET |
|||
echo "[Install]" >>$TARGET |
|||
echo "WantedBy=multi-user.target" >>$TARGET |
|||
|
|||
systemctl enable $UNIT |
|||
systemctl start $UNIT |
|||
|
|||
gtk-bookmarks-update |
|||
DISPLAY=:0.0 pcmanfm -n file://$MNT >/dev/null 2>&1 |
|||
fi |
|||
fi |
|||
fi |
|||
|
|||
if [ "$ACTION" = "remove" ]; then |
|||
systemctl disable $UNIT |
|||
rm "$TARGET" |
|||
rmdir "$MNT" |
|||
gtk-bookmarks-update |
|||
fi |
@ -1,3 +0,0 @@ |
|||
# live user is default user in minios. |
|||
# It needs passwordless sudo functionality. |
|||
live ALL=(ALL) NOPASSWD:ALL |
Loading…
Reference in new issue