amarok.live.remaster.part1.sh
来自「Amarok是一款在LINUX或其他类UNIX操作系统中运行的音频播放器软件。 」· Shell 代码 · 共 140 行
SH
140 行
#!/usr/bin/env bash#set -x ############################################################################# Disassemble an amaroK LiveCD iso file into a specified directory# for the purpose of adding a users own music and putting it back together## Based on a script authored by Ivan Kerekes <ikerekes@gmail.com># and modified by Leo Franchi <lfranchi at gmaildotcom>, Mike Diehl # <madpenguin8 at yahoodotcom> and Greg Meyer <greg at gkmwebdotcom> ## See the file called README for more information############################################################################## This program is free software; you can redistribute it and/or modify# it under the terms of the GNU General Public License as published by# the Free Software Foundation; either version 2 of the License, or# (at your option) any later version.############################################################################## We need to be root to mount the loopback# check for root and exit if notif [ `/usr/bin/whoami` = 'root' ]; thenkdialog --title "amaroK livecd remaster" --yesno "Welcome to the amaroK live cd remaster utility. The first step is to select the iso image, would you like to continue."if [ $? = 0 ] ; theniso=`kdialog --getopenfilename /home "*.iso"`WORK=`kdialog --title "Choose working directory" --getexistingdirectory .`if [ $WORK = 0 ] ; then exit;fi# Determine if enough spaceredo=0enough=0tmp=$WORKwhile [ "$redo" = "0" ]; do while [ "$enough" = "0" ]; do # loops until found something if [[ -n `df | grep $tmp` ]] ; then # we got it in df, find the space left anotmp=`df | grep $tmp | sed "s~^\([^ ]*\) *\([^ ]*\) *\([^ ]*\) *\([^ ]*\) *\([^ ]*\) *\([^ ]*\)$~\4~"` # now we have a string, first item is free space in / free=`echo $anotmp | sed "s~^\([^ ]*\) \(.*\)~\1~"` # get first space-delimited item echo "comparing" $free "to 1572864" if [[ $free -gt 1572864 ]] ; then enough=1 redo=1 break else kdialog --sorry "Not enough free space. Please select another folder." break fi else res=`echo "$tmp" | sed "s~/\(.*\)/\([^/]*\)$~/\1~"` if [[ "$tmp" = "$res" ]]; then # last one, regexp fails here tmp="/" else #normal, removes one dir from path tmp=$res fi echo "new tmp: " $tmp fi done if [[ "$redo" = "0" ]]; then WORK=`kdialog --title "Choose working directory" --getexistingdirectory .` tmp=$WORK if [[ "$?" == 0 ]]; then break else exit fi enough=0 fidone# Mount the iso if not already mountedif [ ! -d "$DATADIR" ]; then DATADIR=$WORK/livecd_data$$ mkdir -p "$DATADIR" mount -o loop "$iso" "$DATADIR"fi# Make the working directories and blow out the initrd.gz into a separate directory mkdir -p $WORK/mklivecd/livecdcp -a --preserve "$DATADIR"/* $WORK/mklivecd/livecd/mkdir -p $WORK/mklivecd/initrd.dirmkdir -p $WORK/mklivecd/initrd.mntgunzip -c $WORK/mklivecd/livecd/isolinux/initrd.gz > $WORK/mklivecd/livecd/isolinux/initrdmount -o loop $WORK/mklivecd/livecd/isolinux/initrd $WORK/mklivecd/initrd.mnt(cd $WORK/mklivecd/initrd.mnt ; tar cf - .) | (cd $WORK/mklivecd/initrd.dir ; tar xf -)umount $WORK/mklivecd/initrd.mntrm -f $WORK/mklivecd/livecd/isolinux/initrd# cleanup all temporary files and directoriesumount "$DATADIR" 2>/dev/null >/dev/nullif [ "$?" = "0" ]; then rmdir $DATADIR; fi# at this point we unsquash the fs so the user can add their own musicif [[ `cat /proc/filesystems | grep squash | wc -l` = 0 ]]; then modprobe squashfs if [[ `cat /proc/filesystems | grep squash | wc -l` = 0 ]]; then kdialog --title "amaroK livecd remaster" --error "You do not have squashfs support enabled. You need to have a patched kernel with squashfs. You can find more info about squashfs, and how to patch your kernel, here: http://tldp.org/HOWTO/SquashFS-HOWTO/" rm -rf $WORK/mklivecd fifimkdir $WORK/amarok.livecd/mount -o loop -t squashfs $WORK/mklivecd/livecd/livecd.sqfs $WORK/amarok.livecd/# gotta copy it locally so the user can add files to itmkdir $WORK/amarok.live/kdialog --title "amaroK livecd remaster" --msgbox "Copying files now. Please be patient, this step takes a long time."echoecho "Please wait, copying in progress."echocp -a $WORK/amarok.livecd/* $WORK/amarok.live/umount $WORK/amarok.livecd/rmdir $WORK/amarok.livecdkdialog --title "amaroK livecd remaster" --msgbox "Copying done. To add music to the amaroK livecd, place additional music in /tmp/amarok.live/music/ Please do not add more than about 380 mb, as then the resulting ISO will be too large to fit on a CD-ROM. Once you are done, run the amarok.live.remaster.part2.sh script and you are finished!."fielse kdialog --title "amaroK livecd remaster" --sorry "You must run this script as root. Try running 'kdesu sh amarok.live.remaster.part1.sh' instead."fi
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?