Merge pull request #689 from Linux4Yourself/issues/686-part-1

Перенесены скрипты
This commit is contained in:
Anton 2021-07-06 19:59:13 +03:00 committed by Anton Maisak
commit f802ab6a31
33 changed files with 889 additions and 46 deletions

View File

@ -12,7 +12,8 @@ rm -rf /tmp/*
logout
```
<common-script :name="'chroot'"></common-script>
[filename](../scripts/chroot.md ':include')
Файлы `.la` потеряли свою актуальность и могут вызвать проблемы при обновлении. Удалите их:

View File

@ -2,7 +2,7 @@
`systemd` требует множество пользователей и групп для своей работы. Создайте их:
<common-script :name="'systemd-users'"></common-script>
[filename](../../scripts/systemd-users.md ':include')
<script>
new Vue({ el: '#main' })

View File

@ -9,8 +9,7 @@
вы могли заметить файлы `~/.profile`, `~/.bash_profile` и ряд других. Они используются для задания элементов окружения для оболочки пользователя. Например, `umask`, а также переменных `PS1` или `PATH`. То же самое и с файлом `/etc/profile`, только он используется для задания общесистемных параметров, а файлы в каталоге пользователя - для задания параметров конкретного пользователя системы.
<common-script :name="'profile'"></common-script>
[filename](../scripts/profile.md ':include')
### О CFLAGS и CXXFLAGS
С помощью данных переменных можно задать флаги компилятора, влияющие в том числе на оптимизацию.
@ -36,29 +35,29 @@
bash-completion расширяет существующие возможности дополнения в bash, позволяя вводить сложные командные строки нажатием буквально нескольких клавиш. Целью является создание программируемых процедур дополнения для большинства распространённых команд Linux/UNIX, которые позволили бы системным администраторам и программистам сократить количество нажатий клавиш при выполнении ежедневных задач.
<common-script :name="'completion'"></common-script>
[filename](../scripts/completion.md ':include')
## Dircolors
Этот файл нужен для цветного вывода таких утилит, как `ls`. Пример: `ls --color=auto`.
<common-script :name="'dircolors'"></common-script>
[filename](../scripts/dircolors.md ':include')
## Readline
Этот файл нужен для настройки `inputrc`. Если пользователь не имеет индивидуальных установок, он использует глобальный файл.
<common-script :name="'inputrc'"></common-script>
[filename](../scripts/inputrc.md ':include')
## Umask
Установка значения `umask` важна для безопасности. Здесь права доступа для записи группы по умолчанию выключены для пользователей системы и когда имена пользователя и группы не совпадают.
<common-script :name="'umask'"></common-script>
[filename](../scripts/umask.md ':include')
## Другие стартовые скрипты
<common-script :name="'other'"></common-script>
[filename](../scripts/other.md ':include')
## Применить изменения

View File

@ -14,7 +14,7 @@ rm -rf /usr/share/{info,man,doc}/*
## Выход из среды chroot
[filename](files/exit-chroot.md ":include")
[filename](../shared/exit-chroot.md ':include')
## Сохранение

View File

@ -31,11 +31,11 @@ fi
Войдите в `chroot`:
<common-script :name="'chroot'"></common-script>
[filename](../scripts/chroot.md ':include')
?> После входа в chroot, в приглашении bash будет написано 'I have no name!'. Это нормально, и ничего плохого в этом нет. Дело в том, что файл `/etc/passwd` ещё не создан.
?> После входа в `chroot`, в приглашении `bash` будет написано ```I have no name!```. Это нормально, и ничего плохого в этом нет. Дело в том, что файл `/etc/passwd` ещё не создан.
[filename](files/exit-chroot.md ':include')
[filename](../shared/exit-chroot.md ':include')
?> Сейчас выполнять действия по выходу из chroot не нужно, это понадобится после окончания сборки системы.

View File

@ -131,25 +131,6 @@ Vue.component('package-script', {
</pre>`,
});
Vue.component('common-script', {
props: {
name: String,
},
data() {
return {
info: null
};
},
mounted() {
selectScript(this.name)
.then(res => (this.info = res));
},
template: `
<pre class="pre">
{{ info }}
</pre>`,
});
Vue.component('warn', {
template: `
<div class="warn-description">

View File

@ -77,10 +77,3 @@ getPackageScript = function (name, script) {
})
.then(response => response.data);
}
selectScript = function(name) {
return axios.get(`${scriptsUrlBase}/${name}.sh`, {
responseType: 'text'
})
.then(response => response.data);
}

View File

@ -317,7 +317,7 @@ chown -R 0:0 /usr/src/linux-{{ package.version }}
Создайте новый файл `/etc/modprobe.d/usb.conf`, выполнив следующую команду:
<common-script :name="'modprobe'"></common-script>
[filename](../scripts/modprobe.md ':include')
<script>
new Vue({ el: '#main' })

View File

@ -16,7 +16,7 @@ mkdir -pv $LIN/tools
Теперь создайте базовую иерархию файловой системы:
<common-script :name="'file-system'"></common-script>
[filename](../scripts/file-system.md ':include')
Подробнее об иерархии каталогов можно узнать в спецификации [FHS](https://refspecs.linuxfoundation.org/fhs.shtml)

View File

@ -61,7 +61,7 @@ urpmi bison gawk texinfo make gcc-c++
Чтобы узнать, что ваша хост-система полностью соответствует всем необходимым для дальнейшей работы требованиям, выполните следующий набор команд:
<common-script :name="'version-check'"></common-script>
[filename](../../scripts/version-check.md ':include')
!> Внимательно изучите результат выполнения. В нём не должно встречаться строк, содержащих `ERROR`, `command not found`, `failed`.

View File

@ -3,7 +3,7 @@
## Обновления пакетов
## 06.07.2021
- [Исправлено 688](https://github.com/Linux4Yourself/Linux4Yourself.Book/issues/688)
- [Исправлено 690](https://github.com/Linux4Yourself/Linux4Yourself.Book/issues/690)
## 05.07.2021

39
docs/scripts/bashrc.md Normal file
View File

@ -0,0 +1,39 @@
```bash
cat > /etc/bashrc << "EOF"
# Begin /etc/bashrc
# Written for Beyond Linux From Scratch
# by James Robertson <jameswrobertson@earthlink.net>
# updated by Bruce Dubbs <bdubbs@linuxfromscratch.org>
# System wide aliases and functions.
# System wide environment variables and startup programs should go into
# /etc/profile. Personal environment variables and startup programs
# should go into ~/.bash_profile. Personal aliases and functions should
# go into ~/.bashrc
# Provides colored /bin/ls and /bin/grep commands. Used in conjunction
# with code in /etc/profile.
alias ls='ls --color=auto'
alias grep='grep --color=auto'
# Provides prompt for non-login shells, specifically shells started
# in the X environment. [Review the LFS archive thread titled
# PS1 Environment Variable for a great case study behind this script
# addendum.]
NORMAL="\[\e[0m\]"
RED="\[\e[1;31m\]"
GREEN="\[\e[1;32m\]"
if [[ $EUID == 0 ]] ; then
PS1="$RED\u [ $NORMAL\w$RED ]# $NORMAL"
else
PS1="$GREEN\u [ $NORMAL\w$GREEN ]\$ $NORMAL"
fi
unset RED GREEN NORMAL
# End /etc/bashrc
EOF
```

View File

@ -0,0 +1,2 @@
umount $LIN/dev{/pts,}
umount $LIN/{sys,proc,run}

7
docs/scripts/chroot.md Normal file
View File

@ -0,0 +1,7 @@
```bash
chroot "$LIN" /usr/bin/env -i \
HOME=/root TERM="$TERM" \
PS1='(chroot) \u:\w\$ ' \
PATH=/usr/bin \
/bin/bash --login
```

View File

@ -0,0 +1,40 @@
```bash
cat > /etc/profile.d/bash_completion.sh << "EOF"
# Begin /etc/profile.d/bash_completion.sh
# Import bash completion scripts
# If the bash-completion package is installed, use its configuration instead
if [ -f /usr/share/bash-completion/bash_completion ]; then
# Check for interactive bash and that we haven't already been sourced.
if [ -n "${BASH_VERSION-}" -a -n "${PS1-}" -a -z "${BASH_COMPLETION_VERSINFO-}" ]; then
# Check for recent enough version of bash.
if [ ${BASH_VERSINFO[0]} -gt 4 ] || \
[ ${BASH_VERSINFO[0]} -eq 4 -a ${BASH_VERSINFO[1]} -ge 1 ]; then
[ -r "${XDG_CONFIG_HOME:-$HOME/.config}/bash_completion" ] && \
. "${XDG_CONFIG_HOME:-$HOME/.config}/bash_completion"
if shopt -q progcomp && [ -r /usr/share/bash-completion/bash_completion ]; then
# Source completion code.
. /usr/share/bash-completion/bash_completion
fi
fi
fi
else
# bash-completions are not installed, use only bash completion directory
if shopt -q progcomp; then
for script in /etc/bash_completion.d/* ; do
if [ -r $script ] ; then
. $script
fi
done
fi
fi
# End /etc/profile.d/bash_completion.sh
EOF
install --directory --mode=0755 --owner=root --group=root /etc/bash_completion.d
```

16
docs/scripts/dircolors.md Normal file
View File

@ -0,0 +1,16 @@
```bash
cat > /etc/profile.d/dircolors.sh << "EOF"
# Setup for /bin/ls and /bin/grep to support color, the alias is in /etc/bashrc.
if [ -f "/etc/dircolors" ] ; then
eval $(dircolors -b /etc/dircolors)
fi
if [ -f "$HOME/.dircolors" ] ; then
eval $(dircolors -b $HOME/.dircolors)
fi
alias ls='ls --color=auto'
alias grep='grep --color=auto'
EOF
dircolors -p > /etc/dircolors
```

View File

@ -0,0 +1,45 @@
```bash
cat > /etc/inputrc << "EOF"
# Begin /etc/inputrc
# Modified by Chris Lynn <roryo@roryo.dynup.net>
# Allow the command prompt to wrap to the next line
set horizontal-scroll-mode Off
# Enable 8bit input
set meta-flag On
set input-meta On
# Turns off 8th bit stripping
set convert-meta Off
# Keep the 8th bit for display
set output-meta On
# none, visible or audible
set bell-style none
# All of the following map the escape sequence of the value
# contained in the 1st argument to the readline specific functions
"\eOd": backward-word
"\eOc": forward-word
# for linux console
"\e[1~": beginning-of-line
"\e[4~": end-of-line
"\e[5~": beginning-of-history
"\e[6~": end-of-history
"\e[3~": delete-char
"\e[2~": quoted-insert
# for xterm
"\eOH": beginning-of-line
"\eOF": end-of-line
# for Konsole
"\e[H": beginning-of-line
"\e[F": end-of-line
# End /etc/inputrc
EOF
```

View File

@ -0,0 +1,26 @@
```bash
mkdir -pv $LIN/{usr,etc,var,lib64}
mkdir -pv $LIN/{boot,home,mnt,opt,srv}
mkdir -pv $LIN/usr/{,local/}{bin,include,lib,src}
mkdir -pv $LIN/{dev,proc,sys,run}
ln -sfv usr/bin $LIN/bin
ln -sfv usr/lib $LIN/lib
ln -sfv usr/bin $LIN/sbin
ln -sfv bin $LIN/usr/sbin
mkdir -pv $LIN/etc/{opt,sysconfig}
mkdir -pv $LIN/lib/firmware
mkdir -pv $LIN/media/{floppy,cdrom}
mkdir -pv $LIN/usr/{,local/}share/{color,dict,doc,info,locale,man}
mkdir -pv $LIN/usr/{,local/}share/{misc,terminfo,zoneinfo}
mkdir -pv $LIN/usr/{,local/}share/man/man{1..8}
mkdir -pv $LIN/var/{cache,local,log,mail,opt,spool}
mkdir -pv $LIN/var/lib/{color,misc,locate}
ln -sfv /run $LIN/var/run
ln -sfv /run/lock $LIN/var/lock
install -dv -m 0750 $LIN/root
install -dv -m 1777 $LIN/tmp $LIN/var/tmp
```

9
docs/scripts/fstab.md Normal file
View File

@ -0,0 +1,9 @@
```bash
cat > /etc/fstab << "EOF"
# file system mount-point type options dump fsck
# order
/dev/sdX / ext4 defaults 1 1
EOF
```

9
docs/scripts/inputrc.md Normal file
View File

@ -0,0 +1,9 @@
```bash
cat > /etc/profile.d/readline.sh << "EOF"
# Setup the INPUTRC environment variable.
if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ] ; then
INPUTRC=/etc/inputrc
fi
export INPUTRC
EOF
```

360
docs/scripts/mkinitramfs.md Normal file
View File

@ -0,0 +1,360 @@
cat > /sbin/mkinitramfs << "EOF"
#!/bin/bash
# This file based in part on the mkinitramfs script for the LFS LiveCD
# written by Alexander E. Patrakov and Jeremy Huntwork.
copy()
{
local file
if [ "$2" = "lib" ]; then
file=$(PATH=/lib:/usr/lib type -p $1)
else
file=$(type -p $1)
fi
if [ -n "$file" ] ; then
cp $file $WDIR/$2
else
echo "Missing required file: $1 for directory $2"
rm -rf $WDIR
exit 1
fi
}
if [ -z $1 ] ; then
INITRAMFS_FILE=initrd.img-no-kmods
else
KERNEL_VERSION=$1
INITRAMFS_FILE=initrd.img-$KERNEL_VERSION
fi
if [ -n "$KERNEL_VERSION" ] && [ ! -d "/lib/modules/$1" ] ; then
echo "No modules directory named $1"
exit 1
fi
mkdir -p /usr/share/mkinitramfs &&
cat > /usr/share/mkinitramfs/init.in << "EOF"
#!/bin/sh
PATH=/bin:/usr/bin:/sbin:/usr/sbin
export PATH
problem()
{
printf "Encountered a problem!\n\nDropping you to a shell.\n\n"
sh
}
no_device()
{
printf "The device %s, which is supposed to contain the\n" $1
printf "root file system, does not exist.\n"
printf "Please fix this problem and exit this shell.\n\n"
}
no_mount()
{
printf "Could not mount device %s\n" $1
printf "Sleeping forever. Please reboot and fix the kernel command line.\n\n"
printf "Maybe the device is formatted with an unsupported file system?\n\n"
printf "Or maybe filesystem type autodetection went wrong, in which case\n"
printf "you should add the rootfstype=... parameter to the kernel command line.\n\n"
printf "Available partitions:\n"
}
do_mount_root()
{
mkdir /.root
[ -n "$rootflags" ] && rootflags="$rootflags,"
rootflags="$rootflags$ro"
case "$root" in
/dev/* ) device=$root ;;
UUID=* ) eval $root; device="/dev/disk/by-uuid/$UUID" ;;
PARTUUID=*) eval $root; device="/dev/disk/by-partuuid/$PARTUUID" ;;
LABEL=* ) eval $root; device="/dev/disk/by-label/$LABEL" ;;
"" ) echo "No root device specified." ; problem ;;
esac
while [ ! -b "$device" ] ; do
no_device $device
problem
done
if ! mount -n -t "$rootfstype" -o "$rootflags" "$device" /.root ; then
no_mount $device
cat /proc/partitions
while true ; do sleep 10000 ; done
else
echo "Successfully mounted device $root"
fi
}
do_try_resume()
{
case "$resume" in
UUID=* ) eval $resume; resume="/dev/disk/by-uuid/$UUID" ;;
LABEL=*) eval $resume; resume="/dev/disk/by-label/$LABEL" ;;
esac
if $noresume || ! [ -b "$resume" ]; then return; fi
ls -lH "$resume" | ( read x x x x maj min x
echo -n ${maj%,}:$min > /sys/power/resume )
}
init=/sbin/init
root=
rootdelay=
rootfstype=auto
ro="ro"
rootflags=
device=
resume=
noresume=false
mount -n -t devtmpfs devtmpfs /dev
mount -n -t proc proc /proc
mount -n -t sysfs sysfs /sys
mount -n -t tmpfs tmpfs /run
read -r cmdline < /proc/cmdline
for param in $cmdline ; do
case $param in
init=* ) init=${param#init=} ;;
root=* ) root=${param#root=} ;;
rootdelay=* ) rootdelay=${param#rootdelay=} ;;
rootfstype=*) rootfstype=${param#rootfstype=} ;;
rootflags=* ) rootflags=${param#rootflags=} ;;
resume=* ) resume=${param#resume=} ;;
noresume ) noresume=true ;;
ro ) ro="ro" ;;
rw ) ro="rw" ;;
esac
done
# udevd location depends on version
if [ -x /sbin/udevd ]; then
UDEVD=/sbin/udevd
elif [ -x /lib/udev/udevd ]; then
UDEVD=/lib/udev/udevd
elif [ -x /lib/systemd/systemd-udevd ]; then
UDEVD=/lib/systemd/systemd-udevd
else
echo "Cannot find udevd nor systemd-udevd"
problem
fi
${UDEVD} --daemon --resolve-names=never
udevadm trigger
udevadm settle
if [ -f /etc/mdadm.conf ] ; then mdadm -As ; fi
if [ -x /sbin/vgchange ] ; then /sbin/vgchange -a y > /dev/null ; fi
if [ -n "$rootdelay" ] ; then sleep "$rootdelay" ; fi
do_try_resume # This function will not return if resuming from disk
do_mount_root
killall -w ${UDEVD##*/}
exec switch_root /.root "$init" "$@"
EOF
printf "Creating $INITRAMFS_FILE... "
binfiles="sh cat cp dd killall ls mkdir mknod mount "
binfiles="$binfiles umount sed sleep ln rm uname"
binfiles="$binfiles readlink basename"
# Systemd installs udevadm in /bin. Other udev implementations have it in /sbin
if [ -x /bin/udevadm ] ; then binfiles="$binfiles udevadm"; fi
sbinfiles="modprobe blkid switch_root"
#Optional files and locations
for f in mdadm mdmon udevd udevadm; do
if [ -x /sbin/$f ] ; then sbinfiles="$sbinfiles $f"; fi
done
# Add lvm if present (cannot be done with the others because it
# also needs dmsetup
if [ -x /sbin/lvm ] ; then sbinfiles="$sbinfiles lvm dmsetup"; fi
unsorted=$(mktemp /tmp/unsorted.XXXXXXXXXX)
DATADIR=/usr/share/mkinitramfs
INITIN=init.in
# Create a temporary working directory
WDIR=$(mktemp -d /tmp/initrd-work.XXXXXXXXXX)
# Create base directory structure
mkdir -p $WDIR/{bin,dev,lib/firmware,run,sbin,sys,proc,usr}
mkdir -p $WDIR/etc/{modprobe.d,udev/rules.d}
touch $WDIR/etc/modprobe.d/modprobe.conf
ln -s lib $WDIR/lib64
ln -s ../bin $WDIR/usr/bin
# Create necessary device nodes
mknod -m 640 $WDIR/dev/console c 5 1
mknod -m 664 $WDIR/dev/null c 1 3
# Install the udev configuration files
if [ -f /etc/udev/udev.conf ]; then
cp /etc/udev/udev.conf $WDIR/etc/udev/udev.conf
fi
for file in $(find /etc/udev/rules.d/ -type f) ; do
cp $file $WDIR/etc/udev/rules.d
done
# Install any firmware present
cp -a /lib/firmware $WDIR/lib
# Copy the RAID configuration file if present
if [ -f /etc/mdadm.conf ] ; then
cp /etc/mdadm.conf $WDIR/etc
fi
# Install the init file
install -m0755 $DATADIR/$INITIN $WDIR/init
if [ -n "$KERNEL_VERSION" ] ; then
if [ -x /bin/kmod ] ; then
binfiles="$binfiles kmod"
else
binfiles="$binfiles lsmod"
sbinfiles="$sbinfiles insmod"
fi
fi
# Install basic binaries
for f in $binfiles ; do
if [ -e /bin/$f ]; then d="/bin"; else d="/usr/bin"; fi
ldd $d/$f | sed "s/\t//" | cut -d " " -f1 >> $unsorted
copy $d/$f bin
done
for f in $sbinfiles ; do
ldd /sbin/$f | sed "s/\t//" | cut -d " " -f1 >> $unsorted
copy $f sbin
done
# Add udevd libraries if not in /sbin
if [ -x /lib/udev/udevd ] ; then
ldd /lib/udev/udevd | sed "s/\t//" | cut -d " " -f1 >> $unsorted
elif [ -x /lib/systemd/systemd-udevd ] ; then
ldd /lib/systemd/systemd-udevd | sed "s/\t//" | cut -d " " -f1 >> $unsorted
fi
# Add module symlinks if appropriate
if [ -n "$KERNEL_VERSION" ] && [ -x /bin/kmod ] ; then
ln -s kmod $WDIR/bin/lsmod
ln -s kmod $WDIR/bin/insmod
fi
# Add lvm symlinks if appropriate
# Also copy the lvm.conf file
if [ -x /sbin/lvm ] ; then
ln -s lvm $WDIR/sbin/lvchange
ln -s lvm $WDIR/sbin/lvrename
ln -s lvm $WDIR/sbin/lvextend
ln -s lvm $WDIR/sbin/lvcreate
ln -s lvm $WDIR/sbin/lvdisplay
ln -s lvm $WDIR/sbin/lvscan
ln -s lvm $WDIR/sbin/pvchange
ln -s lvm $WDIR/sbin/pvck
ln -s lvm $WDIR/sbin/pvcreate
ln -s lvm $WDIR/sbin/pvdisplay
ln -s lvm $WDIR/sbin/pvscan
ln -s lvm $WDIR/sbin/vgchange
ln -s lvm $WDIR/sbin/vgcreate
ln -s lvm $WDIR/sbin/vgscan
ln -s lvm $WDIR/sbin/vgrename
ln -s lvm $WDIR/sbin/vgck
# Conf file(s)
cp -a /etc/lvm $WDIR/etc
fi
# Install libraries
sort $unsorted | uniq | while read library ; do
# linux-vdso and linux-gate are pseudo libraries and do not correspond to a file
# libsystemd-shared is in /lib/systemd, so it is not found by copy, and
# it is copied below anyway
if [[ "$library" == linux-vdso.so.1 ]] ||
[[ "$library" == linux-gate.so.1 ]] ||
[[ "$library" == libsystemd-shared* ]]; then
continue
fi
copy $library lib
done
if [ -d /lib/udev ]; then
cp -a /lib/udev $WDIR/lib
fi
if [ -d /lib/systemd ]; then
cp -a /lib/systemd $WDIR/lib
fi
if [ -d /lib/elogind ]; then
cp -a /lib/elogind $WDIR/lib
fi
# Install the kernel modules if requested
if [ -n "$KERNEL_VERSION" ]; then
find \
/lib/modules/$KERNEL_VERSION/kernel/{crypto,fs,lib} \
/lib/modules/$KERNEL_VERSION/kernel/drivers/{block,ata,md,firewire} \
/lib/modules/$KERNEL_VERSION/kernel/drivers/{scsi,message,pcmcia,virtio} \
/lib/modules/$KERNEL_VERSION/kernel/drivers/usb/{host,storage} \
-type f 2> /dev/null | cpio --make-directories -p --quiet $WDIR
cp /lib/modules/$KERNEL_VERSION/modules.{builtin,order} \
$WDIR/lib/modules/$KERNEL_VERSION
depmod -b $WDIR $KERNEL_VERSION
fi
( cd $WDIR ; find . | cpio -o -H newc --quiet | gzip -9 ) > $INITRAMFS_FILE
# Prepare early loading of microcode if available
if ls /lib/firmware/intel-ucode/* >/dev/null 2>&1 ||
ls /lib/firmware/amd-ucode/* >/dev/null 2>&1; then
# first empty WDIR to reuse it
rm -r $WDIR/*
DSTDIR=$WDIR/kernel/x86/microcode
mkdir -p $DSTDIR
if [ -d /lib/firmware/amd-ucode ]; then
cat /lib/firmware/amd-ucode/microcode_amd*.bin > $DSTDIR/AuthenticAMD.bin
fi
if [ -d /lib/firmware/intel-ucode ]; then
cat /lib/firmware/intel-ucode/* > $DSTDIR/GenuineIntel.bin
fi
( cd $WDIR; find . | cpio -o -H newc --quiet ) > microcode.img
cat microcode.img $INITRAMFS_FILE > tmpfile
mv tmpfile $INITRAMFS_FILE
rm microcode.img
fi
# Remove the temporary directories and files
rm -rf $WDIR $unsorted
printf "done.\n"
EOF
chmod 0755 /sbin/mkinitramfs

57
docs/scripts/mkiso.md Normal file
View File

@ -0,0 +1,57 @@
#!/bin/bash
if [ $(id -u) != 0 ]; then
echo "$0 script need to run as root!"
exit 1
fi
trap "exit 1" SIGHUP SIGINT SIGQUIT SIGTERM
LIN_VER=1.0.0
CWD=$PWD
WDIR=/tmp/lx4uiso
ISOLINUXDIR=$CWD/livecd/isolinux
DISTRONAME="Lx4u"
LABEL=Lx4uLiveCD
LIN_ROOT=$LIN
OUTPUT=Lx4u-$LIN_VER-livecd.iso
isolinux_files="chain.c32 isolinux.bin ldlinux.c32 libutil.c32 reboot.c32 menu.c32
isohdpfx.bin isolinux.cfg libcom32.c32 poweroff.c32"
rm -rf $WDIR
mkdir -pv $WDIR
# prepare isolinux in working dir
mkdir -p $WDIR/{filesystem,isolinux,boot}
for file in $isolinux_files; do
cp $ISOLINUXDIR/$file $WDIR/isolinux
done
echo "$DISTRONAME" > $WDIR/isolinux/linuxlive
[ -d livecd/virootfs ] && cp -aR livecd/virootfs $WDIR
cp $LIN_ROOT/boot/vmlinuz-* $WDIR/boot/vmlinuz
#cp $LIN_ROOT/boot/initrd-*-lfs.img $WDIR/boot/initrd
mksquashfs $LIN_ROOT $WDIR/filesystem/root.sfs \
-b 1048576 -comp xz -Xdict-size 100% \
-e $LIN_ROOT/tools/ \
-e $LIN_ROOT/tmp/*
rm -f $OUTPUT
xorriso -as mkisofs \
-r -J -joliet-long \
-l -cache-inodes \
-isohybrid-mbr $ISOLINUXDIR/isohdpfx.bin \
-partition_offset 16 \
-volid "$LABEL" \
-b isolinux/isolinux.bin \
-c isolinux/boot.cat \
-no-emul-boot \
-boot-load-size 4 \
-boot-info-table \
-o $OUTPUT \
$WDIR
rm -fr $WDIR

9
docs/scripts/modprobe.md Normal file
View File

@ -0,0 +1,9 @@
```bash
install -v -m755 -d /etc/modprobe.d
cat > /etc/modprobe.d/usb.conf << "EOF"
# Begin /etc/modprobe.d/usb.conf
install ohci_hcd /sbin/modprobe ehci_hcd ; /sbin/modprobe -i ohci_hcd ; true
install uhci_hcd /sbin/modprobe ehci_hcd ; /sbin/modprobe -i uhci_hcd ; true
# End /etc/modprobe.d/usb.conf
EOF
```

52
docs/scripts/other.md Normal file
View File

@ -0,0 +1,52 @@
```bash
cat > ~/.bash_profile << "EOF"
if [ -f "$HOME/.bashrc" ] ; then
source $HOME/.bashrc
fi
if [ -d "$HOME/bin" ] ; then
pathprepend $HOME/bin
fi
# End ~/.bash_profile
EOF
cat > ~/.profile << "EOF"
# Begin ~/.profile
# Personal environment variables and startup programs.
if [ -d "$HOME/bin" ] ; then
pathprepend $HOME/bin
fi
# Set up user specific i18n variables
#export LANG=<ll>_<CC>.<charmap><@modifiers>
# End ~/.profile
EOF
cat > ~/.bashrc << "EOF"
# Begin ~/.bashrc
# Written for Beyond Linux From Scratch
# by James Robertson <jameswrobertson@earthlink.net>
# Personal aliases and functions.
# Personal environment variables and startup programs should go in
# ~/.bash_profile. System wide environment variables and startup
# programs are in /etc/profile. System wide aliases and functions are
# in /etc/bashrc.
if [ -f "/etc/bashrc" ] ; then
source /etc/bashrc
fi
if [ -f "/etc/profile" ] ; then
source /etc/profile
fi
# Set up user specific i18n variables
#export LANG=<ll>_<CC>.<charmap><@modifiers>
# End ~/.bashrc
EOF
```

87
docs/scripts/profile.md Normal file
View File

@ -0,0 +1,87 @@
```bash
cat > /etc/profile << "EOF"
# Begin /etc/profile
# Written for Beyond Linux From Scratch and modified for Linux4yourself
# by James Robertson <jameswrobertson@earthlink.net>
# modifications by Dagmar d'Surreal <rivyqntzne@pbzpnfg.arg>
# modifications for Linux4yourself by makpif <citokot@gmail.com>
# System wide environment variables and startup programs.
# System wide aliases and functions should go in /etc/bashrc. Personal
# environment variables and startup programs should go into
# ~/.bash_profile. Personal aliases and functions should go into
# ~/.bashrc.
# Functions to help us manage paths. Second argument is the name of the
# path variable to be modified (default: PATH)
pathremove () {
local IFS=':'
local NEWPATH
local DIR
local PATHVARIABLE=${2:-PATH}
for DIR in ${!PATHVARIABLE} ; do
if [ "$DIR" != "$1" ] ; then
NEWPATH=${NEWPATH:+$NEWPATH:}$DIR
fi
done
export $PATHVARIABLE="$NEWPATH"
}
pathprepend () {
pathremove $1 $2
local PATHVARIABLE=${2:-PATH}
export $PATHVARIABLE="$1${!PATHVARIABLE:+:${!PATHVARIABLE}}"
}
pathappend () {
pathremove $1 $2
local PATHVARIABLE=${2:-PATH}
export $PATHVARIABLE="${!PATHVARIABLE:+${!PATHVARIABLE}:}$1"
}
export -f pathremove pathprepend pathappend
# Set the initial path
export PATH=/usr/bin:/usr/sbin
# Setup some environment variables.
export HISTSIZE=1000
export HISTIGNORE="&:[bf]g:exit"
# Set some defaults for graphical systems
export XDG_DATA_DIRS=${XDG_DATA_DIRS:-/usr/share/}
export XDG_CONFIG_DIRS=${XDG_CONFIG_DIRS:-/etc/xdg/}
export XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR:-/tmp/xdg-$USER}
# Setup a red prompt for root and a green one for users.
NORMAL="\[\e[0m\]"
RED="\[\e[1;31m\]"
GREEN="\[\e[1;32m\]"
if [[ $EUID == 0 ]] ; then
PS1="$RED\u [ $NORMAL\w$RED ]# $NORMAL"
else
PS1="$GREEN\u [ $NORMAL\w$GREEN ]\$ $NORMAL"
fi
for script in /etc/profile.d/*.sh ; do
if [ -r $script ] ; then
. $script
fi
done
unset script RED GREEN NORMAL
# CFLAGS and CXXFLAGS for optimization (if you want - add -march=native)
export CFLAGS="-O3 -s"
export CXXFLAGS="-O3 -s"
# makeflags for paralell make
export MAKEFLAGS=-j$(lscpu | grep "CPU(s):" | grep -v NUMA | tr -d "CPU(s): ")
# End /etc/profile
EOF
install --directory --mode=0755 --owner=root --group=root /etc/profile.d
```

8
docs/scripts/rosa.md Normal file
View File

@ -0,0 +1,8 @@
#!/bin/bash
if [ `whoami` -ne "root" ]; then
echo "Запустите этот скрипт от имени root! Выход."
exit 0
fi
urpmi bison gawk texinfo make gcc-c++

View File

@ -0,0 +1,24 @@
```bash
cat >> /etc/passwd << "EOF"
systemd-bus-proxy:x:72:72:systemd Bus Proxy:/:/bin/false
systemd-journal-gateway:x:73:73:systemd Journal Gateway:/:/bin/false
systemd-journal-remote:x:74:74:systemd Journal Remote:/:/bin/false
systemd-journal-upload:x:75:75:systemd Journal Upload:/:/bin/false
systemd-network:x:76:76:systemd Network Management:/:/bin/false
systemd-resolve:x:77:77:systemd Resolver:/:/bin/false
systemd-timesync:x:78:78:systemd Time Synchronization:/:/bin/false
systemd-coredump:x:79:79:systemd Core Dumper:/:/bin/false
systemd-oom:x:81:81:systemd Out Of Memory Daemon:/:/bin/false
EOF
cat >> /etc/group << "EOF"
systemd-bus-proxy:x:72:
systemd-journal-gateway:x:73:
systemd-journal-remote:x:74:
systemd-journal-upload:x:75:
systemd-network:x:76:
systemd-resolve:x:77:
systemd-timesync:x:78:
systemd-coredump:x:79:
systemd-oom:x:81:81:
EOF
```

6
docs/scripts/ubuntu.md Normal file
View File

@ -0,0 +1,6 @@
```bash
#!/bin/bash
apt-get install build-essential bison gawk texinfo
ln -sf bash /bin/sh
```

10
docs/scripts/umask.md Normal file
View File

@ -0,0 +1,10 @@
```bash
cat > /etc/profile.d/umask.sh << "EOF"
# By default, the umask should be set.
if [ "$(id -gn)" = "$(id -un)" -a $EUID -gt 99 ] ; then
umask 002
else
umask 022
fi
EOF
```

View File

@ -0,0 +1,64 @@
```bash
cat > version-check.sh << "EOF"
#!/bin/bash
# Simple script to list version numbers of critical development tools
export LC_ALL=C
bash --version | head -n1 | cut -d" " -f2-4
MYSH=$(readlink -f /bin/sh)
echo "/bin/sh -> $MYSH"
echo $MYSH | grep -q bash || echo "ERROR: /bin/sh does not point to bash"
unset MYSH
echo -n "Binutils: "; ld --version | head -n1 | cut -d" " -f3-
bison --version | head -n1
if [ -h /usr/bin/yacc ]; then
echo "/usr/bin/yacc -> `readlink -f /usr/bin/yacc`";
elif [ -x /usr/bin/yacc ]; then
echo yacc is `/usr/bin/yacc --version | head -n1`
else
echo "yacc not found"
fi
bzip2 --version 2>&1 < /dev/null | head -n1 | cut -d" " -f1,6-
echo -n "Coreutils: "; chown --version | head -n1 | cut -d")" -f2
diff --version | head -n1
find --version | head -n1
gawk --version | head -n1
if [ -h /usr/bin/awk ]; then
echo "/usr/bin/awk -> `readlink -f /usr/bin/awk`";
elif [ -x /usr/bin/awk ]; then
echo awk is `/usr/bin/awk --version | head -n1`
else
echo "awk not found"
fi
gcc --version | head -n1
g++ --version | head -n1
ldd --version | head -n1 | cut -d" " -f2- # glibc version
grep --version | head -n1
gzip --version | head -n1
cat /proc/version
m4 --version | head -n1
make --version | head -n1
patch --version | head -n1
echo Perl `perl -V:version`
python3 --version
sed --version | head -n1
tar --version | head -n1
makeinfo --version | head -n1 # texinfo version
xz --version | head -n1
echo 'int main(){}' > dummy.c && g++ -o dummy dummy.c
if [ -x dummy ]
then echo "g++ compilation OK";
else echo "g++ compilation failed"; fi
rm -f dummy.c dummy
EOF
bash version-check.sh
```

View File

@ -17,7 +17,7 @@
Создайте файл `fstab`:
<common-script :name="'fstab'"></common-script>
[filename](../../scripts/fstab.md ':include')
Замените `sdX` на нужное значение.

View File

@ -4,8 +4,7 @@
Создайте данный файл:
<common-script :name="'etc-inputrc'"></common-script>
[filename](../../scripts/etc-inputrc.md ':include')
<script>
new Vue({ el: '#main' })
</script>