File: config-cdcontrol

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 (110 lines) | stat: -rwxr-xr-x 3,479 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/bin/bash
# Configure the drives (enabling/disabling by hand)

function cdcontrol_config {
 local L_WRITTER L_WRITTER_0 L_TMPFILE L_WRTLIST L_STATUS L_SAIDA_CFG L_Recorder1 L_Recorder2 L_Recorder3 L_Recorder4 L_Recorder5 L_Recorder6 L_Recorder7 L_Recorder8 L_Recorder9 L_Recorder10 L_Recorder11 L_Recorder12 L_Recorder13 L_Recorder14 L_Recorder15 L_Recorder16 L_Recorder17 L_Recorder18 L_Recorder19 L_Recorder20

# Read the initial state of each drive (enabled/disabled) placing the value on
# sequential variables from 1 to 99
for L_WRITTER in `seq 1 ${WRITTERS}`;do
 cat ${CFG_DIR}/Recorder${L_WRITTER}.cfg|grep 'ENABLED=1' >/dev/null
 if [ $? = 0 ];then
  eval L_Recorder${L_WRITTER}="on"
 else
  eval L_Recorder${L_WRITTER}="off"
 fi
done


L_TMPFILE=`mktemp /tmp/fileXXXXXX`

${DIALOG} --backtitle $"CDcontrol v${CDC_VERSION}" \
        --title $"Enable/Disable Writters" \
        --checklist $"From this screen you can enable/disable\n\
CD writters used by CDcontrol.\n\
Press space bar to toggle enable/disabled from that writter,\n\
press <Enter> to confirm. Press <Esc> ou select 'Cancel'\n\
to exit" 18 65 8 \
$(for L_WRITTER in `seq 1 ${WRITTERS}`;do
 L_STATUS=$(echo `eval echo \$\{L_Recorder$(echo ${L_WRITTER})\}`)
 echo "Writter_${L_WRITTER} Writter_${L_WRITTER}_configuration `echo ${L_STATUS}`"
done
) 2> ${L_TMPFILE}

case $? in
  1)
   clear
   ${DIALOG} --backtitle $"CDcontrol v${CDC_VERSION}" \
      --msgbox $"Canceled by user." 7 40
   rm -f ${L_TMPFILE}
   exit 1
   ;;
  255)
   clear
   ${DIALOG} --backtitle $"CDcontrol v${CDC_VERSION}" \
     --msgbox $"Canceled by user." 7 40
   rm -f ${L_TMPFILE}
   exit 1
   ;;
esac

# Cut off the "" and the "Writter_" word from selection
L_WRTLIST=`cat ${L_TMPFILE}|sed -e s/"\""//g -e s/'Writter_'//g`
rm -f ${L_TMPFILE}

# Add a 0 ahead of numbers 1 to 9 to avoid comparation errors adding the 
# results to variable L_SAIDA_CFG
L_SAIDA_CFG=""
for L_WRITTER in ${L_WRTLIST};do
 if [ ${L_WRITTER} -lt 10 ];then
  L_SAIDA_CFG=`echo "${L_SAIDA_CFG} 0${L_WRITTER}"`
 else
  L_SAIDA_CFG=`echo "${L_SAIDA_CFG} ${L_WRITTER}"`
 fi
done

# Confirmation about the status chaning of drives
${DIALOG} --backtitle $"CDcontrol v${CDC_VERSION}" --title $"Confirmation" \
   --yesno $"Do you like to save the configuration? press <Enter>\n\
to save. Press <Esc> or select 'No' to exit:" 7 61
case $? in
 0)
  clear
  # Add a 0 ahead of numbers 1 to 9 to avoit comparation errors and adding the
  # results to L_WRITTER_0 variable
  for L_WRITTER in `seq 1 ${WRITTERS}`;do
   if [ ${L_WRITTER} -lt 10 ];then
    L_WRITTER_0=`echo "0${L_WRITTER}"`
    else
    L_WRITTER_0=`echo "${L_WRITTER}"`
   fi
   # If the variable L_SAIDA_CFG had the number, means that writter was enabled
   if echo ${L_SAIDA_CFG}|grep "${L_WRITTER_0}" >/dev/null;then
    echo $"The writter ${L_WRITTER} was enabled"
    sed -e s/"ENABLED=.*"/'ENABLED=1'/ \
        -e s/"OBS=.*"/'OBS='/ \
    ${CFG_DIR}/Recorder${L_WRITTER}.cfg >${TMP_DIR}/Recorder${L_WRITTER}-config.temp
   else
    echo "The writter ${L_WRITTER} was disabled"
    sed -e s/"ENABLED=.*"/'ENABLED=0'/ \
        -e s/"OBS=.*"/'OBS=Disabled by the user'/ \
    ${CFG_DIR}/Recorder${L_WRITTER}.cfg >${TMP_DIR}/Recorder${L_WRITTER}-config.temp
   fi
   mv -f ${TMP_DIR}/Recorder${L_WRITTER}-config.temp \
         ${CFG_DIR}/Recorder${L_WRITTER}.cfg
  done
  echo $"Press <Enter> to continue..."
  read
  ;;
 1)
  exit 1
  ;;
 255)
  exit 1
  ;;
esac

exit 0
}

cdcontrol_config