Pastebin
API
tools
faq
paste
Login
Sign up
Please fix the following errors:
New Paste
Syntax Highlighting
#!/bin/sh set -e # Required Syslinux version sysver=4.05 sysbin=syslinux extbin=extlinux sysmbr=/usr/share/syslinux/mbr_c.bin sysmbr2=/usr/lib/syslinux/mbr_c.bin mattrbin=mattrib # Directories for ldlinux.sys and bundled syslinux binary sysdir=/liberte/boot/syslinux systmpdir= mntexec= # Filesystem types (for auto mode) fs_fat=4d44 fs_ext=ef53 if [ ! \( $# = 1 -o \( $# = 2 -a "$2" = nombr \) -o "$1" = automagic \) ]; then cat <<EOF This script installs SYSLINUX or EXTLINUX on a device with Liberté Linux. You need the following installed. Syslinux ${sysver} (Gentoo: sys-boot/syslinux) [if unavailable, bundled 32-bit version will be used] udev + sysfs (Gentoo: sys-fs/udev) [available on most modern Linux distributions] Run setup.sh as: setup.sh auto [nombr] setup.sh /dev/XXX [nombr] If the optional <nombr> parameter is specified, and /dev/XXX is a partition, then the block device's master boot record will be unaffected. Use this parameter when a custom bootloader is installed in the MBR. EOF exit 1 fi # Arguments dev="$1" nombr="$2" # Error handling error() { echo "$@" exit 1 } # Handle auto mode if [ "${dev}" = auto ]; then echo "*** Determining device name ***" shift mpoint=`readlink -f "$0"` if [ "${mpoint}" = "${mpoint%/liberte/setup.sh}" ]; then error "Bad script path" fi mpoint="${mpoint%/liberte/setup.sh}" if ! mountpoint -q "${mpoint}"; then error "${mpoint} is not a mount point" fi fstype=`stat -f -c "%t" "${mpoint}"` fsdev=/dev/block/`mountpoint -d "${mpoint}"` fsdev=`readlink -f "${fsdev}"` case "${fstype}" in ${fs_fat}) echo "${fsdev} is mounted as FAT(32) on ${mpoint}" setup=`mktemp` cp $0 "${setup}" exec /bin/sh "${setup}" automagic "${mpoint}" "${fsdev}" "$@" ;; ${fs_ext}) echo "${fsdev} is mounted as ext[234] on ${mpoint}" exec /bin/sh "$0" "${fsdev}" "$@" ;; *) error "Unknown filesystem type" ;; esac error "Internal error" fi if [ "${dev}" = automagic ]; then mpoint="$2" shift 2 echo "Unmounting ${mpoint}" umount "${mpoint}" /bin/sh "$0" "$@" exec rm "$0" error "Internal error" fi # Check that the argument is a block device if [ ! -b "${dev}" ]; then error "${dev} is not a block device." fi # Check for pre-4.x Syslinux (without the -v switch) sysok=0 extok=0 if ! ${sysbin} -v 1>/dev/null 2>&1; then echo "Syslinux v4+ not found, will use bundled binary" elif [ ! -e ${sysmbr} -a ! -e ${sysmbr2} ]; then echo "${sysmbr} or ${sysmbr2} not found, will use bundled Syslinux" else # Check for wrong Syslinux version (exact match required) havesysver=`${sysbin} -v 2>&1 | cut -d' ' -f2` if [ "${havesysver}" != ${sysver} ]; then echo "Syslinux v${havesysver} detected, need v${sysver}" else sysok=1 if [ -e ${sysmbr2} ]; then sysmbr=${sysmbr2} fi if ! ${extbin} -v 1>/dev/null 2>&1; then echo "EXTLINUX not found, will use bundled binary if installing to ext[234]" else extok=1 fi fi fi # udev properties accessor udevprop() { local devpath="$1" prop="$2" udevadm info -q property -p "${devpath}" | sed -n "s/^${prop}=//p" } # 32-bit executability checker checkexec() { local binary="$1" # 32-bit: /lib/ld-linux.so.2, 64-bit: /lib/ld-linux-x86-64.so.2 if [ ! -e /lib/ld-linux.so.2 ]; then echo "WARNING: it looks like 32-bit ELF binaries are unsupported on this system" # Use test(1) from coreutils (it calls access(2), honoring MS_NOEXEC and MS_RDONLY) elif [ ! -x "${binary}" ] || { [ -e /usr/bin/test ] && ! /usr/bin/test -x "${binary}"; }; then echo "WARNING: executing bundled binaries will fail" binary=`dirname "$(readlink -f "${binary}")"` while ! mountpoint -q ${binary}; do binary=`dirname "${binary}"` done if grep -q " ${binary} .*\<noexec\>" /proc/mounts; then mntexec="${binary}" echo "WARNING: ${mntexec} is mounted with noexec option" echo "Remounting ${mntexec} with exec permissions" mount -o remount,exec "${mntexec}" fi fi } # Check for wrong block device type (highly unlikely) devpath=`udevadm info -q path -n "${dev}"` devtype=`udevprop ${devpath} DEVTYPE` if [ "${devtype}" != partition -a "${devtype}" != disk ]; then error "${dev} is neither a disk nor a disk partition" fi # Check and normalize filesystem type devfs=`udevprop "${devpath}" ID_FS_TYPE` case "${devfs}" in '') error "${dev} is not formatted, format it as FAT/ext2 or specify a partition instead" ;; vfat|msdos) echo "Detected FAT(32) filesystem, will install using SYSLINUX" devfs=fat ;; ext[234]) echo "Detected ext[234] filesystem, will install using EXTLINUX" devfs=ext2 ;; *) error "${dev} has a [${devfs}] filesystem type, need FAT/ext2" ;; esac if [ ${devfs} = fat ]; then # Check for mounted filesystem (be a bit paranoid, so no '$' after ${dev}) if cut -d' ' -f1 /proc/mounts | grep -q "^${dev}"; then error "${dev} is mounted, unmount it or wait for auto-unmount" fi # Check for installation directory mntdir=`mktemp -d` mount -r -t vfat -o noatime,nosuid,nodev,noexec "${dev}" ${mntdir} if [ -e ${mntdir}${sysdir}/syslinux-x86.tbz ]; then hassysdir=1 else hassysdir=0 fi # Copy bundled syslinux binary if system versions are wrong if [ ${hassysdir} = 1 -a ${sysok} = 0 ]; then echo "Using bundled 32-bit SYSLINUX/Mtools binaries and MBR" systmpdir=`mktemp -d` tar -xpjf ${mntdir}${sysdir}/syslinux-x86.tbz -C ${systmpdir} sysbin=${systmpdir}/syslinux sysmbr=${systmpdir}/mbr_c.bin mattrbin=${systmpdir}/mattrib export PATH=${systmpdir}:"${PATH}" checkexec ${sysbin} fi # Create OTFE directory so that it can be hidden, too if [ ! -e ${mntdir}/otfe ]; then mount -o remount,rw ${mntdir} mkdir ${mntdir}/otfe fi umount -l ${mntdir} rmdir ${mntdir} if [ ${hassysdir} = 0 ]; then error "Directory ${sysdir} not found or incorrect on ${dev}" fi # Install SYSLINUX echo "*** Installing SYSLINUX on ${dev} ***" ${sysbin} -i -d ${sysdir} "${dev}" # Hide directories echo "*** Hiding top-level directories ***" unset MTOOLSRC export MTOOLS_SKIP_CHECK=1 export MTOOLS_FAT_COMPATIBILITY=1 ${mattrbin} -i "${dev}" +h ::/liberte ::/otfe ${mattrbin} -i "${dev}" +h ::/EFI 2>/dev/null || : if [ -n "${mntexec}" ]; then echo "Remounting ${mntexec} with noexec option" mount -o remount,noexec "${mntexec}" fi elif [ ${devfs} = ext2 ]; then devdir=`grep "^${dev} " /proc/mounts | head -n 1 | cut -d' ' -f2` if [ -n "${devdir}" ] && mountpoint -q "${devdir}"; then echo "Detected ${dev} mount on ${devdir}" else error "${dev} is not mounted, please manually mount or auto-mount it" fi if [ ! -e "${devdir}"${sysdir}/syslinux-x86.tbz ]; then error "Directory ${sysdir} not found or incorrect in ${devdir}" elif [ ${extok} = 0 ]; then echo "Using bundled 32-bit EXTLINUX binary and MBR" systmpdir=`mktemp -d` tar -xpjf "${devdir}"${sysdir}/syslinux-x86.tbz -C ${systmpdir} extbin=${systmpdir}/extlinux sysmbr=${systmpdir}/mbr_c.bin checkexec ${extbin} fi # Install EXTLINUX echo "*** Installing EXTLINUX in ${devdir} ***" ${extbin} -i "${devdir}"${sysdir} if [ -n "${mntexec}" ]; then echo "Remounting ${mntexec} with noexec option" mount -o remount,noexec "${mntexec}" fi else error "Internal error" fi # If necessary, install Syslinux-supplied MBR if [ -z "${nombr}" -a ${devtype} = partition ]; then # Get the parent device rdevpath=`dirname "${devpath}"` rdev=`udevprop "${rdevpath}" DEVNAME` echo "*** Installing bootloader to the MBR of ${rdev} ***" # Check that the parent device is a block device if [ ! -b "${rdev}" ]; then error "${rdev} is not a block device." fi # Check that the parent device is indeed a disk rdevtype=`udevprop "${rdevpath}" DEVTYPE` if [ "${rdevtype}" != disk ]; then error "${rdev} is not a disk, but ${rdevtype}, aborting" fi # Check that the disk is a removable device if [ -e /sys"${rdevpath}"/removable ]; then if [ "`cat /sys"${rdevpath}"/removable`" = 0 ]; then echo "WARNING: ${rdev} is not a removable device"'!' echo "Press Ctrl-C now to abort (waiting 10 seconds)..." sleep 10 fi fi # Check that the partition table is MSDOS ptable=`udevprop "${rdevpath}" ID_PART_TABLE_TYPE` if [ "${ptable}" != dos ]; then error "Partition table is of type [${ptable}], need MS-DOS" fi # Determine partition number if [ ! -e /sys"${devpath}"/partition ]; then error "Unable to reliably determine partition number of ${dev}" fi devpart=`cat /sys"${devpath}"/partition` # Install Syslinux's MBR (less than 512B, doesn't overwrite the partition table) if ! type sfdisk 1>/dev/null 2>&1; then error "sfdisk not found, cannot mark partition ${devpart} active" fi echo running sfdisk -q -A"${devpart}" "${rdev}" sfdisk -q -A"${devpart}" "${rdev}" echo ran sfdisk -q -A"${devpart}" "${rdev}" dd bs=440 count=1 iflag=fullblock conv=notrunc if=${sysmbr} of="${rdev}" fi # Remove temporary directories if [ -n "${systmpdir}" ]; then rm -r ${systmpdir} fi # Synchronize echo "*** Synchronizing ***" sync echo "*** Done ***"
Optional Paste Settings
Category:
None
Cryptocurrency
Cybersecurity
Fixit
Food
Gaming
Haiku
Help
History
Housing
Jokes
Legal
Money
Movies
Music
Pets
Photo
Science
Software
Source Code
Spirit
Sports
Travel
TV
Writing
Tags:
Syntax Highlighting:
None
Bash
C
C#
C++
CSS
HTML
JSON
Java
JavaScript
Lua
Markdown (PRO members only)
Objective C
PHP
Perl
Python
Ruby
Swift
4CS
6502 ACME Cross Assembler
6502 Kick Assembler
6502 TASM/64TASS
ABAP
AIMMS
ALGOL 68
APT Sources
ARM
ASM (NASM)
ASP
ActionScript
ActionScript 3
Ada
Apache Log
AppleScript
Arduino
Asymptote
AutoIt
Autohotkey
Avisynth
Awk
BASCOM AVR
BNF
BOO
Bash
Basic4GL
Batch
BibTeX
Blitz Basic
Blitz3D
BlitzMax
BrainFuck
C
C (WinAPI)
C Intermediate Language
C for Macs
C#
C++
C++ (WinAPI)
C++ (with Qt extensions)
C: Loadrunner
CAD DCL
CAD Lisp
CFDG
CMake
COBOL
CSS
Ceylon
ChaiScript
Chapel
Clojure
Clone C
Clone C++
CoffeeScript
ColdFusion
Cuesheet
D
DCL
DCPU-16
DCS
DIV
DOT
Dart
Delphi
Delphi Prism (Oxygene)
Diff
E
ECMAScript
EPC
Easytrieve
Eiffel
Email
Erlang
Euphoria
F#
FO Language
Falcon
Filemaker
Formula One
Fortran
FreeBasic
FreeSWITCH
GAMBAS
GDB
GDScript
Game Maker
Genero
Genie
GetText
Go
Godot GLSL
Groovy
GwBasic
HQ9 Plus
HTML
HTML 5
Haskell
Haxe
HicEst
IDL
INI file
INTERCAL
IO
ISPF Panel Definition
Icon
Inno Script
J
JCL
JSON
Java
Java 5
JavaScript
Julia
KSP (Kontakt Script)
KiXtart
Kotlin
LDIF
LLVM
LOL Code
LScript
Latex
Liberty BASIC
Linden Scripting
Lisp
Loco Basic
Logtalk
Lotus Formulas
Lotus Script
Lua
M68000 Assembler
MIX Assembler
MK-61/52
MPASM
MXML
MagikSF
Make
MapBasic
Markdown (PRO members only)
MatLab
Mercury
MetaPost
Modula 2
Modula 3
Motorola 68000 HiSoft Dev
MySQL
Nagios
NetRexx
Nginx
Nim
NullSoft Installer
OCaml
OCaml Brief
Oberon 2
Objeck Programming Langua
Objective C
Octave
Open Object Rexx
OpenBSD PACKET FILTER
OpenGL Shading
Openoffice BASIC
Oracle 11
Oracle 8
Oz
PARI/GP
PCRE
PHP
PHP Brief
PL/I
PL/SQL
POV-Ray
ParaSail
Pascal
Pawn
Per
Perl
Perl 6
Phix
Pic 16
Pike
Pixel Bender
PostScript
PostgreSQL
PowerBuilder
PowerShell
ProFTPd
Progress
Prolog
Properties
ProvideX
Puppet
PureBasic
PyCon
Python
Python for S60
QBasic
QML
R
RBScript
REBOL
REG
RPM Spec
Racket
Rails
Rexx
Robots
Roff Manpage
Ruby
Ruby Gnuplot
Rust
SAS
SCL
SPARK
SPARQL
SQF
SQL
SSH Config
Scala
Scheme
Scilab
SdlBasic
Smalltalk
Smarty
StandardML
StoneScript
SuperCollider
Swift
SystemVerilog
T-SQL
TCL
TeXgraph
Tera Term
TypeScript
TypoScript
UPC
Unicon
UnrealScript
Urbi
VB.NET
VBScript
VHDL
VIM
Vala
Vedit
VeriLog
Visual Pro Log
VisualBasic
VisualFoxPro
WHOIS
WhiteSpace
Winbatch
XBasic
XML
XPP
Xojo
Xorg Config
YAML
YARA
Z80 Assembler
ZXBasic
autoconf
jQuery
mIRC
newLISP
q/kdb+
thinBasic
Paste Expiration:
Never
Burn after read
10 Minutes
1 Hour
1 Day
1 Week
2 Weeks
1 Month
6 Months
1 Year
Paste Exposure:
Public
Unlisted
Private
Folder:
(members only)
Password
NEW
Enabled
Disabled
Burn after read
NEW
Paste Name / Title:
Create New Paste
Hello
Guest
Sign Up
or
Login
Sign in with Facebook
Sign in with Twitter
Sign in with Google
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login
Public Pastes
I made $15,000 * 2 hours
CSS | 15 min ago | 0.99 KB
✅ API Glitch (Docs Leak)
CSS | 15 min ago | 0.99 KB
Custom Placeholder: Event Image using alt tag...
6 hours ago | 0.50 KB
Untitled
Bash | 16 hours ago | 1.17 KB
Using Prepared statement with bind vars to pr...
Go | 21 hours ago | 3.67 KB
rc
1 day ago | 2.49 KB
Stripe Session Vars
2 days ago | 0.67 KB
[TLF 16] Hylandra's File / Introduction
2 days ago | 3.37 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the
Cookies Policy
.
OK, I Understand
Not a member of Pastebin yet?
Sign Up
, it unlocks many cool features!