File: cd-memory

package info (click to toggle)
cdcontrol 1.90-1.1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 160 kB
  • ctags: 16
  • sloc: sh: 944; makefile: 26
file content (91 lines) | stat: -rwxr-xr-x 3,100 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash
# Write a CD imagem to hard disk from a CD

FREE_SPC=$(echo $[`df -m | grep "${IMG_PARTITION}" | awk '{print $4}'`/655])

#--------[ Check free space before to write the image ]------------
if [ ${FREE_SPC} = 0 ];then
 ${DIALOG}  --backtitle $"CDcontrol v${CDC_VERSION}" --title $"Alert!" --clear \
   --msgbox $"You don't have enought free space on your partition to write a new,\n\
CD image. Select the 'Erase' option from the main menu or free up some space\n\
on your disk to write CDControl disk image. Press <Enter>" 0 0 
 exit 1
fi

#-------------------[ Dialog Processing ]----------------------------
L_TMPFILE=`mktemp /tmp/fileXXXXXX`

${DIALOG}  --backtitle $"CDcontrol v${CDC_VERSION}" \
        --title $"Type the CD name" --clear \
       --inputbox $"Type the CD name in the space bellow and press\n\
<ENTER>. There is space for ${FREE_SPC} full (740MB) CD images\n\
on your disk." \
        10 51 2> ${L_TMPFILE}
retval=$?
CD_NAME=`cat ${L_TMPFILE}|sed -e s/' '/'_'/g`
rm -f ${L_TMPFILE}
case $retval in
  0)
   if [ -z ${CD_NAME} ];then
     ${DIALOG} --backtitle $"CDcontrol v${CDC_VERSION}" \
         --msgbox $"Canceled by user." 7 40
    exit 1
   fi
    ;;
  1)
     ${DIALOG} --backtitle $"CDcontrol v${CDC_VERSION}" \
         --msgbox $"Canceled by user." 7 40
    exit 1;;
  255)
     ${DIALOG} --backtitle $"CDcontrol v${CDC_VERSION}" \
         --msgbox $"Canceled by user." 7 40
    exit 1;;
esac
#----------------------------------------------------------------------------------

if [ ! -d "${IMG_DIR}/${CD_NAME}" -a "${IMG_TYPE}" = "A" ];then 
 mkdir -p "${IMG_DIR}/${CD_NAME}" >/dev/null
fi

if [ "${IMG_TYPE}" = "A" ];then
 if ! cd "${IMG_DIR}/${CD_NAME}" >/dev/null;then
     ${DIALOG} --backtitle $"CDcontrol v${CDC_VERSION}" \
         --msgbox $"Could not possible write to disk, chech if the access permissions are ok and try again" 0 0
  exit 1
 fi
elif [ "${IMG_TYPE}" = "D" ];then
 cd "${IMG_DIR}"
fi

clear
if [ "${IMG_TYPE}" = "A" ];then
     ${DIALOG} --backtitle $"CDcontrol v${CDC_VERSION}" \
         --infobox $"Reading the audio CD \"${CD_NAME}\". Please wait..." 7 60
elif [ "${IMG_TYPE}" = "D" ];then
     ${DIALOG} --backtitle $"CDcontrol v${CDC_VERSION}" \
         --infobox $"Reading the data CD \"${CD_NAME}\". Please wait..." 7 60
fi

if [ "${IMG_TYPE}" = "A" ];then
 cdda2wav -x -v255 -D${CD_READER} -B -S${R_SPEED} -Owav track
elif [ "${IMG_TYPE}" = "D" ];then
 dd if=${CD_READER} of="${CD_NAME}.iso"
fi

# Check if the image was written with sucesfull checking the las
# program exitcode
if [ "$?" = "0" ];then
 clear
 ${DIALOG} --backtitle $"CDcontrol v${CDC_VERSION}" \
   --msgbox $"CD \"${CD_NAME}\" sucessfully written to the memory." 7 40
else
 ${DIALOG} --backtitle $"CDcontrol v${CDC_VERSION}" \
   --msgbox $"Failed to write \"${CD_NAME}\" to the memory. The most probably cause
   for this is disk errors or a CD drive failing to read." 7 40
 if [ "${IMG_TYPE}" = "A" ];then
  rm -rf "${IMG_DIR}/${CD_NAME}" >/dev/null
 elif [ "${IMG_TYPE}" = "D" ];then
  rm -rf "${IMG_DIR}/${CD_NAME}.iso" >/dev/null
 fi
fi
exit 0