Sun Oct 13, 2013 7:01 pm
#!/usr/bin/env bash
# if yad is installed, use in preference
if [[ -f /usr/bin/yad ]]; then
DIALOG="yad"
INFO="image=gtk-dialog-info"
QUESTION="image=gtk-dialog-question"
WARNING="image=gtk-dialog-warning"
ERROR="image=gtk-dialog-error"
#buttons
BUTTON0="button"
BUTTON1="button"
BUTTON0NUM=":0"
BUTTON1NUM=":1"
#cancel button always returns 1 as $?
#ok button always returns 0 as $?
#ok is default (highlighted)
#buttons in yad dialog window may show reversed from zenity window, e.g.
#yad: ok -- cancel (0 -- 1)
#zenity: cancel -- ok (1 -- 0)
elif [[ -f /usr/bin/zenity ]]; then
# use zenity
DIALOG="zenity"
INFO="info"
QUESTION="question"
WARNING="warning"
ERROR="error"
#buttons
BUTTON0="ok-label"
BUTTON1="cancel-label"
BUTTON0NUM=""
BUTTON1NUM=""
else
xterm -fa monaco -fs 12 -hold -e echo "
Neither Yad nor Zenity is installed. You can't run the GUI version of
Refracta Installer without one of those. Instead, you can run
'refractainstaller' from a terminal or console for the CLI version.
"
fi
# Check disk space on mounted filesystems.
check_space () {
disk_space=$(df -h -x tmpfs -x devtmpfs -x iso9660 | awk '{ print " " $2 "\t" $3 "\t" $4 "\t" $5 " \t" $6 "\t\t\t" $1 }')
#disk_space=$(df -h -x tmpfs -x devtmpfs -x iso9660 | awk '{ print " " $2 "\t" $3 "\t" $4 "\t" $5 " \t" $6 "\t\t\t" $1 }' | tee >($DIALOG --title="Checking disk space..." --progress --pulsate --auto-close --width 300) ;)
#disk_space=$(df -h -x tmpfs -x devtmpfs | awk '{ print $2 "\t" $3 "\t" $4 "\t" $5 "\t" $6 "\t\t\t"}{ printf (%-32s, $1) }')
#disk_space=$(df -h -x tmpfs -x devtmpfs | awk '{ print $2 "\t" $3 "\t" $4 "\t" $5 "\t" }{ printf "%-18s", $6 }{ printf "%-28s", $1 "\n" }')
#disk_space=$(df -h -x tmpfs -x devtmpfs | awk '{ printf "%-.32s", $1 }{ print "\t" $2 "\t" $3 "\t" $4 "\t" $5 "\t" $6 }')
#disk_space=$(df -h -x tmpfs -x devtmpfs | awk '{ printf "%-40s", $1 "\t" }{ print "\t" $2 "\t" $3 "\t" $4 "\t" $5 "\t" $6 }')
}
# Put information in a zenity or yad window to show current settings and disk space
report_space () {
$DIALOG --$QUESTION --title="Disk Space and Settings Report" --${BUTTON0}="Create Snapshot"${BUTTON0NUM} \
--${BUTTON1}="Exit"${BUTTON1NUM} --height=550 --width=920 \
--text "Please CLOSE any running applications NOW.
You will need plenty of free space. It is recommended that free space (Avail) in the partition that holds the work directory (probably \"/\") should be two times the total installed system size (Used).
You can deduct the space taken up by previous snapshots and any saved copies of the system from the Used amount.
* You have $snapshot_count snapshots taking up $snapshot_size of disk space.
$saved_copy
$save_message
* The snapshot directory is currently set to $snapshot_dir
$tmp_warning
You can change these and other settings by editing
$configfile.
Current disk usage:
(For complete listing, exit and run 'df -h')
$disk_space
"
if [ $? -ne 0 ]; then
exit 0
fi
}
check_space
report_space
echo "Done! "
#!/usr/bin/env bash
# if yad is installed, use in preference
#if [[ -f /usr/bin/yad ]]; then
DIALOG="yad"
INFO="image=gtk-dialog-info"
QUESTION="image=gtk-dialog-question"
WARNING="image=gtk-dialog-warning"
ERROR="image=gtk-dialog-error"
#buttons
BUTTON0="button"
BUTTON1="button"
BUTTON0NUM=":0"
BUTTON1NUM=":1"
#cancel button always returns 1 as $?
#ok button always returns 0 as $?
#ok is default (highlighted)
#buttons in yad dialog window may show reversed from zenity window, e.g.
#yad: ok -- cancel (0 -- 1)
#zenity: cancel -- ok (1 -- 0)
#el
if [[ -f /usr/bin/zenity ]]; then
# use zenity
DIALOG="zenity"
INFO="info"
QUESTION="question"
WARNING="warning"
ERROR="error"
#buttons
BUTTON0="ok-label"
BUTTON1="cancel-label"
BUTTON0NUM=""
BUTTON1NUM=""
else
xterm -fa monaco -fs 12 -hold -e echo "
Neither Yad nor Zenity is installed. You can't run the GUI version of
Refracta Installer without one of those. Instead, you can run
'refractainstaller' from a terminal or console for the CLI version.
"
fi
# Check disk space on mounted filesystems.
check_space () {
disk_space=$(df -h -x tmpfs -x devtmpfs -x iso9660 | awk '{ print " " $2 "\t" $3 "\t" $4 "\t" $5 " \t" $6 "\t\t\t" $1 }')
#disk_space=$(df -h -x tmpfs -x devtmpfs -x iso9660 | awk '{ print " " $2 "\t" $3 "\t" $4 "\t" $5 " \t" $6 "\t\t\t" $1 }' | tee >($DIALOG --title="Checking disk space..." --progress --pulsate --auto-close --width 300) ;)
#disk_space=$(df -h -x tmpfs -x devtmpfs | awk '{ print $2 "\t" $3 "\t" $4 "\t" $5 "\t" $6 "\t\t\t"}{ printf (%-32s, $1) }')
#disk_space=$(df -h -x tmpfs -x devtmpfs | awk '{ print $2 "\t" $3 "\t" $4 "\t" $5 "\t" }{ printf "%-18s", $6 }{ printf "%-28s", $1 "\n" }')
#disk_space=$(df -h -x tmpfs -x devtmpfs | awk '{ printf "%-.32s", $1 }{ print "\t" $2 "\t" $3 "\t" $4 "\t" $5 "\t" $6 }')
#disk_space=$(df -h -x tmpfs -x devtmpfs | awk '{ printf "%-40s", $1 "\t" }{ print "\t" $2 "\t" $3 "\t" $4 "\t" $5 "\t" $6 }')
}
# Put information in a zenity or yad window to show current settings and disk space
report_space () {
$DIALOG --$QUESTION --title="Disk Space and Settings Report" --${BUTTON0}="Create Snapshot"${BUTTON0NUM} \
--${BUTTON1}="Exit"${BUTTON1NUM} --height=550 --width=920 \
--text "Please CLOSE any running applications NOW.
You will need plenty of free space. It is recommended that free space (Avail) in the partition that holds the work directory (probably \"/\") should be two times the total installed system size (Used).
You can deduct the space taken up by previous snapshots and any saved copies of the system from the Used amount.
* You have $snapshot_count snapshots taking up $snapshot_size of disk space.
$saved_copy
$save_message
* The snapshot directory is currently set to $snapshot_dir
$tmp_warning
You can change these and other settings by editing
$configfile.
Current disk usage:
(For complete listing, exit and run 'df -h')
$disk_space
"
if [ $? -ne 0 ]; then
exit 0
fi
}
check_space
report_space
echo "Done! "
Sun Oct 13, 2013 10:42 pm
Sun Oct 13, 2013 10:48 pm
Mon Oct 14, 2013 12:23 am
Mon Oct 14, 2013 3:50 am
Mon Oct 14, 2013 9:07 am
Neither Yad nor Zenity is installed. You can't run the GUI version of
Refracta Installer without one of those. Instead, you can run
'refractainstaller' from a terminal or console for the CLI version.
Mon Oct 14, 2013 10:24 am
disk_space=$(df -h -x tmpfs -x devtmpfs -x iso9660 | awk '{ print " " $2 "\t" $3 " \t" $4 " \t" $5 " \t" $6 "\t\t\t" $1 }')
Mon Oct 14, 2013 1:45 pm
Mon Oct 14, 2013 1:56 pm
df -h -x tmpfs -x devtmpfs -x iso9660|grep -v Filesystem| $DIALOG --list --title="Disk Space and Settings Report" --separator="" --column "Filesystem Size Used Avail Use% Mountpoint" --${BUTTON0}="Create Snapshot"${BUTTON0NUM} \
--${BUTTON1}="Exit"${BUTTON1NUM} --height=550 --width=920 \
--text "Please CLOSE any running applications NOW.
You will need plenty of free space. It is recommended that free space (Avail) in the partition that holds the work directory (probably \"/\") should be two times the total installed system size (Used).
You can deduct the space taken up by previous snapshots and any saved copies of the system from the Used amount.
* You have $snapshot_count snapshots taking up $snapshot_size of disk space.
$saved_copy
$save_message
* The snapshot directory is currently set to $snapshot_dir
$tmp_warning
You can change these and other settings by editing
$configfile.
Current disk usage:
(For complete listing, exit and run 'df -h')"
Mon Oct 14, 2013 8:21 pm
fsmithred wrote:nadir - could you try again after adding some spaces before the tabs in the awk command, like this:
- Code:
disk_space=$(df -h -x tmpfs -x devtmpfs -x iso9660 | awk '{ print " " $2 "\t" $3 " \t" $4 " \t" $5 " \t" $6 "\t\t\t" $1 }')