# refracta.freeforums.org

place to talk about refracta

Skip to content

Welcome
Welcome to refracta You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. In addition, registered members also see less advertisements. Registration is fast, simple, and absolutely free, so please, join our community today!

## Is this post OK

If it's not on-topic, it's in here.
Post a reply
45 posts • Page 2 of 5 • 1, 2, 3, 4, 5

### Re: Is this post OK

by fsmithred » Mon Apr 08, 2013 1:52 pm

There's no excuse for your behavior, and it is much appreciated. That's the kind of stuff I (obviously) miss. Thanks.
If you don't like the blkid window, do you like one of these presentations better (for selecting a partition). I need to see more than just the device name, and I suspect that dzz has the same problem - lots of partitions. (14 here) Now, if I could combine the information from both of these, I'd be very happy.
Run as root -

Code: Select all
  `#!/usr/bin/env bash
  # select_device
  selection1=$(/sbin/blkid |grep /dev/sd | zenity --list --separator "" --column "" --height 450 --width 680)
  echo "selection1 = $selection1"
  device1=$(echo $selection1 | awk -F: '{ print $1 }')
  echo "You selected $device1"
  selection2=$(lshw -short -class volume | awk '{ print $2 "\t" $4 " " $5 " " $6 " " $7 }' | zenity --list --separator "" --column "" --height 450 --width 400)
  device2=$(echo $selection2 | awk '{ print $1 }')
  echo "Your second selection was $device2"
  `

fsmithred
  Posts: 2101
  Joined: Wed Mar 09, 2011 9:13 pm

Top

### Re: Is this post OK

by fsmithred » Mon Apr 08, 2013 4:22 pm

Hmm... that 40-second gap represents about 300 lines of code. A lot of that gets skipped if you don't choose certain options, but I guess it's still a lot of stuff happening. I think I could put up an info window that would hang around until it gets killed, but I'm not sure if it would hide any subsequent windows, and it might look strange to have it there if you've chosen some of those other options and other windows are coming up.
If you're up for experimenting, try this.
Put this between "copy separate /boot" and "create swapfile" (around line 932 in refractainstaller-yad and around 876 in refractainstaller-gui)

Code: Select all
  `yad --info --text="Stuff is happening."`

and then put this before the sudoers section (around line 1221 in yad version and 1132 in zenity version). You could move it to earlier locations to locate the source of the lag, but that's a lot of installs to mess with.

Code: Select all
  `kill $(pgrep zenity)
  or
  kill $(pgrep yad)`

fsmithred
  Posts: 2101
  Joined: Wed Mar 09, 2011 9:13 pm

Top

### Re: Is this post OK

by ukbrian » Mon Apr 08, 2013 4:24 pm

> There's no excuse for your behavior, and it is much appreciated. That's the kind of stuff I (obviously) miss.

Looks like I did something right for once
Quite a time ago I asked Anthony Nordquist to add partition labels to his installer and the answer was "It's never going to happen" so I dropped it but a few months later he created the first script for Grub Doctor which only listed the partitions as sda1, sda2 etc so I posted an image of his selection screen alongside an image of gparted which displayed the partition labels etc and that got a reaction.
He quite quickly done a rewrite of grub doctor using an array for the display but also added those routines to his installer scripts. It might be the sort of thing your looking for.
I would suggest that you only need one column for the partition size and that would be better displayed as a percentage 0.00 GiB, the other column could be for the file system then.

Code: Select all
  `#!/bin/bash
  # Licensed under the GNU General Public License Version 2
  #
  # 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.
  #
  # This program is distributed in the hope that it will be useful,
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  # GNU General Public License for more details.
  #
  # You should have received a copy of the GNU General Public License
  # along with this program; if not, write to the Free Software
  # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  ####################################################################################################
  ## Copyright 2009-2012 Anthony Nordquist and Tony Brijeski
  ## Some of this code was borrowed from Tony Brijeski's Remastersys installer and Remastersys grub restore utility, and he deserves lots of credit for having code worth jacking. This code has been modified to suit the purpose of this program :)
  Question='yad --wrap --center --image=gtk-dialog-question --button=gtk-no:1 --button=gtk-yes:0 --title=Grub-Doctor --window-icon=/usr/share/pixmaps/grub-doctor.png'
  Info='yad --center --title=Grub-Doctor --window-icon=/usr/share/pixmaps/grub-doctor.png'
  ## Cry like a little girl if we don't have root
  TestRoot="$(whoami)"
  if [ "$TestRoot" != "root" ]; then
  yad --title="Grub Doctor" --text="Must be run with root privileges, will now exit" --button=$"gtk-ok:1"
  exit 0
  fi
  ## Just in case people don't know what this is, inform them.
  $Question --width=200 --text="This is a boot-loader restoration utility (GRUB2). Would you like to restore the system boot-loader?"
  if [ "$?" != "0" ]; then
  exit 0
  fi
  ## Need to get the root partition from the user.
  Drives=$(cat /proc/partitions | grep -v loop | grep -v "Extended" | grep -v "extended" | grep -v "swap" | grep -v "Swap" | grep -v "Hidden" | grep -v major | grep -v "^$" | awk '{ print $4}')
  for i in $Drives; do
  PartDrive="$i"
  ## Get the label of the disk if available
  Label=$(find /dev/disk/by-label/* -printf %f" "%l\\n | grep "$PartDrive" | awk '{print $1}' | sed -e 's|\\x20| |g')
  if [ "$Label" = "" ]; then
  Label=' '
  else
  Label="$Label "
  fi
  PartDriveSize=$(grep -m 1 "$i" /proc/partitions | awk '{print $3}')
  ## Part Drive Size is in blocks, first we need to convert the blocks to bytes
  ## Don't bother with extended partitions
  if [ "$PartDriveSize" != "1" ]; then
  BlockSize=$(df -P /dev/$PartDrive | grep "blocks" | awk '{print $2}' | awk -F '-' '{print $1}')
  ## Multiply blocks by block size to get bytes
  SizeInBytes=$(($PartDriveSize * $BlockSize))
  ## Divide Bytes by 1024 to get Kilobytes
  SizeInKB=$(($SizeInBytes / 1024))
  ## Divide Kilobytes by 1024 to get Megabytes
  SizeInMB=$(($SizeInKB / 1024))
  ## Divide Megabytes by 1024 to get Gigabytes
  SizeInGB=$(($SizeInMB / 1024))
  ## Bash always removes the decimels causing it to round down, this makes it round up.
  SizeInGB=$(($SizeInGB + 1))
  fi
  if [ "$(echo "$PartDrive" | grep [0-9] )" != "" ]; then
  if [ "$PartDriveSize" != "1" ]; then
  if [ "$PartDriveMenu" = "" ]; then
  PartDriveMenu=("$PartDrive" "$Label" "$SizeInGB" "$SizeInMB")
  else
  PartDriveMenu=("${PartDriveMenu[@]}" "$PartDrive" "$Label" "$SizeInGB" "$SizeInMB")
  fi
  fi
  fi
  if [ "$(echo "$PartDrive" | grep [0-9] )" = "" ]; then
  GrubMenu=("${GrubMenu[@]}" "$PartDrive" "Master boot record of disk")
  fi
  done
  GrubMenu=("${GrubMenu[@]}" "root" "Root Partition (Advanced)")
  GetRootPart () {
  RootPart=""
  RootPart=$(yad --height="300" --list --window-icon="/usr/share/pixmaps/grub-doctor.png" --title="Grub Doctor" --column="Name" --column="Partition Label" --column="Approx. Size in GiB" --column="Approx. Size in MiB" --print-column=1 --button=$"gtk-quit:3" --button=$"gtk-ok:2" --text="Please select the root partition of SalineOS, or another GRUB2 based distribution." "${PartDriveMenu[@]}")
  ret="$?"
  if [ "$ret" = "3" ]; then
  $Question --text="Are you sure you want to cancel the installation?"
  if [ "$?" = "0" ]; then
  exit 0
  else
  GetRootPart
  exit 0
  fi
  elif [ "$ret" = "252" ]; then
  GetRootPart
  exit 0
  elif [ "$RootPart" = "" ]; then
  $Info --text="No partition selected, please retry." --button=$"gtk-ok:1"
  GetRootPart
  exit 0
  fi
  RootPart=$(echo "$RootPart" | awk -F '|' '{print $1}')
  }
  GetRootPart
  ## Find out where grub is going
  GetGrubLocation (){
  GrubLocation=""
  GrubLocation=$(yad --list --window-icon="/usr/share/pixmaps/grub-doctor.png" --title="Grub Doctor" --column="Name" --column="Description" --height="300" --width="275" --wrap --button=$"gtk-quit:3" --button=$"gtk-ok:2" --text=" Please select where to install grub. \n" "${GrubMenu[@]}")
  ret="$?"
  if [ "$ret" = "3" ]; then
  $Question --text="Are you sure you want to cancel the installation?"
  if [ "$?" = "0" ]; then
  exit 0
  else
  GetGrubLocation
  exit 0
  fi
  elif [ "$ret" = "252" ]; then
  $Question --text="Are you sure you want to cancel the installation?"
  if [ "$?" = "0" ]; then
  exit 0
  else
  GetGrubLocation
  exit 0
  fi
  elif [ "$GrubLocation" = "" ]; then
  $Info --text="No location selected, please retry." --button=$"gtk-ok:1"
  GetGrubLocation
  exit 0
  fi
  GrubLocation=$(echo "$GrubLocation" | awk -F '|' '{print $1}')
  if [ "$GrubLocation" = "root" ]; then
  GrubLocation="/dev/$RootPart"
  else
  GrubLocation="/dev/$GrubLocation"
  fi
  }
  GetGrubLocation
  ## Ask for confirmation before we do anything drastic
  $Question --text="Grub will be installed on "$GrubLocation"\n\nContinue with operation?"
  if [ "$?" = "1" ]; then
  $Info --text="Operation cancelled, will now exit" --button=$"gtk-ok:1"
  exit
  fi
  ## Start Progress bar
  tail -f /usr/bin/grub-doctor | yad --center --pulsate --progress --auto-close --title="Grub Doctor" --no-buttons --window-icon=/usr/share/pixmaps/grub-doctor.png --text=" Installing and setting up grub...Please Wait \n" &
  GrubDir="$(mount | grep $RootPart | awk '{print$3}')"
  if [ "$GrubDir" != "/" ]; then
  umount "$GrubDir"
  umount -l "$GrubDir"
  GrubDir="/tmp/remmnt/Target"
  ## Mount the root directory
  umount "/dev/$RootPart"
  umount -l "/dev/$RootPart"
  sleep 2
  if [ ! -d $GrubDir ]; then
  mkdir -p $GrubDir
  fi
  mount /dev/$RootPart $GrubDir -o rw
  ## Check to ensure that the partition was mounted properly.
  if [ "$(mount | grep "/dev/$RootPart" | awk '{print $3}')" != "/tmp/remmnt/Target" ]; then
  if [ "$GrubDir" != "/" ]; then
  killall -KILL tail
  yad --width="250" --wrap --window-icon="/usr/share/pixmaps/grub-doctor" --title="Grub Doctor" --text="Failed to mount $RootPart, please ensure there are no files in use on the partition and then run Grub Doctor again." --button=$"gtk-quit:1"
  exit 0
  fi
  fi
  ## Check the archetecture of host system and root partition matches.
  Arch1="$(file /usr/bin/file | awk '{print $3}')"
  Arch2="$(file /tmp/remmnt/Target/usr/bin/file | awk '{print $3}')"
  if [ "$Arch1" != "$Arch2" ]; then
  killall -KILL tail
  yad --width="250" --wrap --window-icon="/usr/share/pixmaps/grub-doctor" --title="Grub Doctor" --text="Archetecture of the host system does not match the selected root partition. To restore grub for $RootPart you will need to run Grub Doctor from a $Arch2 system." --button=$"gtk-quit:1"
  umount -l /tmp/remmnt/Target
  exit 0
  fi
  ## Prepare chroot
  mount -o bind /proc $GrubDir/proc
  mount -o bind /dev $GrubDir/dev
  mount -o bind /sys $GrubDir/sys
  ## The meat and potatoes of this script
  chroot $GrubDir grub-install --force --no-floppy "$GrubLocation"
  chroot $GrubDir update-grub
  ## Dismount
  umount $GrubDir/proc
  umount $GrubDir/dev
  umount $GrubDir/sys
  else
  grub-install --no-floppy --force "$GrubLocation"
  update-grub
  fi
  ## Unmount partition
  umount -l /tmp/remmnt/Target
  ## Stop the progress bar
  TailPID=$(pgrep -f "tail -f /usr/bin/grub-doctor")
  kill $TailPID
  ## Tell the user we are done now
  $Info --text=" Grub installation complete. \n" --button=$"gtk-ok:1"
  ##
  #
  exit 0`

ukbrian
  Posts: 109
  Joined: Mon Jul 25, 2011 8:22 am
  Location: Cheltenham, UK

Top

### Re: Is this post OK

by fsmithred » Tue Apr 09, 2013 2:01 pm

Rolled your changes into a new .deb (9.0.8-2, gui package only). The blkid window is still there, and the partition display hasn't changed, but I'll look at using an array. Thanks for that.
http://distro.ibiblio.org/refracta/testing/

fsmithred
  Posts: 2101
  Joined: Wed Mar 09, 2011 9:13 pm

Top

### Re: Is this post OK

by ukbrian » Wed Apr 10, 2013 1:07 pm

I've got a little funny happening with both the snapshot scripts after editing the text files I get the screen with the message "This may take a moment while the program checks for free space."
This screen has a title of "YAD"?
After I press "OK" I get this error message "Error.. The selected snapshot directory cannot be accessed. Do you need to mount it?"
If I press "OK" the script shuts down.
The snapshot dir is set to the default of "/home/snapshot".
This happens with and without Yad installed.
Also with refractasnapshot-gui
line 238
I'm trying to add height 600 as I'm running 1280x720 and the controls(buttons) at the bottom are off screen
i've tried
--width 600 --height 600
and
--width=600 --height=600
# 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} --width 600 --height 600 \
--text "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).

ukbrian
  Posts: 109
  Joined: Mon Jul 25, 2011 8:22 am
  Location: Cheltenham, UK

Top

### Re: Is this post OK

by fsmithred » Wed Apr 10, 2013 2:53 pm

Oh, woops. Around line 200, change two instances of 'else' to 'elif [blah]'

Code: Select all
  `if [ -n "$snapdir_is_remote" ] && cat /proc/mounts | grep -q ${snapdir_is_remote}; then
  echo "$snapshot_dir is mounted"
  else
  $DIALOG --$ERROR --title="Refracta Snapshot" --text=" Error.. The selected snapshot directory cannot be accessed. Do you need to mount it? "
  exit 1
  fi
  if [ -n "$workdir_is_remote" ] && cat /proc/mounts | grep -q ${workdir_is_remote}; then
  echo "$work_dir is mounted"
  else
  $DIALOG --$ERROR --title="Refracta Snapshot" --text=" Error.. The selected work directory cannot be accessed. Do you need to mount it? "
  exit 1
  fi`

Like this:

Code: Select all
  `if [ -n "$snapdir_is_remote" ] && cat /proc/mounts | grep -q ${snapdir_is_remote}; then
  echo "$snapshot_dir is mounted"
  elif [ -n "$snapdir_is_remote" ] ; then
  $DIALOG --$ERROR --title="Refracta Snapshot" --text=" Error.. The selected snapshot directory cannot be accessed. Do you need to mount it? "
  exit 1
  fi
  if [ -n "$workdir_is_remote" ] && cat /proc/mounts | grep -q ${workdir_is_remote}; then
  echo "$work_dir is mounted"
  elif [ -n "$workdir_is_remote" ] ; then
  $DIALOG --$ERROR --title="Refracta Snapshot" --text=" Error.. The selected work directory cannot be accessed. Do you need to mount it? "
  exit 1
  fi`

I think that's correct. Note that this will only test for things mounted under /media. If you're putting your work directory or snapshot directory on something that should or will be mounted somewhere else, you are responsible for knowing whether it's mounted or not.
When I add a height setting of 600 to the information window, it comes out taller than without. Try changing the width to 920 and don't set the height (or set it smaller if you need to.)
Edit: uploaded corrected debs to the testing folder at 14:59 UTC

fsmithred
  Posts: 2101
  Joined: Wed Mar 09, 2011 9:13 pm

Top

### Re: Is this post OK

by ukbrian » Wed Apr 10, 2013 5:40 pm

That sorted it out
I still can't get that height bit going but the height is OK with Yad installed so maybe best to have Yad installed.
I'll give it a good thrashing tomorrow.

ukbrian
  Posts: 109
  Joined: Mon Jul 25, 2011 8:22 am
  Location: Cheltenham, UK

Top

### Re: Is this post OK

by ukbrian » Thu Apr 11, 2013 10:30 am

I only run 32 bit OS's and yesterday I was running SolydX Wheezy Xfce with a 3.2.0-4 kernel without Yad
Today I'm running on Solusos 1.3 Squeeze Gnome with Xfce 4.8 added and a 3.3.6 kernel without Yad and I'm not getting a height problem with the "Disk Space and Settings Report" screen, everything is good.
I make my videos for novice users so I try to simplify things as much as possible so there's less explanations/talking, I try to make the picture tell the story so I don't have to talk much.
What I'd like to do is remove the "Setup" bit that uses a text editor as the different OS's all seem to use different editors which makes things a bit messy.
I think the only bit my novices would want to change in the refractasnapshot.conf is the
snapshot-basename="snapshot" which just leaves the excludes and Anthony has done a very good routine for that which I think you could use.
I'm doing a video of running it so you can see what I mean, I did suggest to him to use the hostname for the snapshot name but he wasn't keen on that but I do like his solution.

ukbrian
  Posts: 109
  Joined: Mon Jul 25, 2011 8:22 am
  Location: Cheltenham, UK

Top

### Re: Is this post OK

by fsmithred » Thu Apr 11, 2013 1:52 pm

I could test for three or four common text editors and use what's there. I think geany, gedit, kwrite and leafpad should do it. And I'll make a way to hard-code it in case someone is using a different one.
Some way to make it easy for the user to understand what to do with the excludes would be nice. Where do I see what you're talking about?

fsmithred
  Posts: 2101
  Joined: Wed Mar 09, 2011 9:13 pm

Top

### Re: Is this post OK

by ukbrian » Thu Apr 11, 2013 4:09 pm

> fsmithred wrote:I could test for three or four common text editors and use what's there. I think geany, gedit, kwrite and leafpad should do it. And I'll make a way to hard-code it in case someone is using a different one.

I think you need Mouspad as well

> Some way to make it easy for the user to understand what to do with the excludes would be nice. Where do I see what you're talking about?

I think you're gonna like this one, not only does it do the excludes it also populates the backup destination it also does the ISO title so a novice doesn't need to go into the .conf file, I would suggest setting the default compression to maximum http://lin.me.uk/demos/saline/saline-backup.tar.xz
I've done quick videos of the backup install and the clone to partition bits which Dean said that his script will do, I've just gotto dub a narration on them and then I'll upload them.
This is Anthony's backup script and as you can see he's already done the bit for adding other languages so it's not just limited to English speakers. http://lin.me.uk/demos/saline/saline-backup-script.tar.xz
I've been thinking about the problems golinux had with the excludes and I can only put it down to the trailing slash, I have used your scripts for at least 2 years using wild cards without any problems but I'm only a user not a coder, I'd be lost without the wild card.

ukbrian
  Posts: 109
  Joined: Mon Jul 25, 2011 8:22 am
  Location: Cheltenham, UK

Top

Previous Next Display posts from previous:
Sort by

Post a reply
45 posts • Page 2 of 5 • 1, 2, 3, 4, 5

Return to General Nonsense

Jump to:

### Who is online

Users browsing this forum: No registered users and 0 guests

Donate Now
ProNight Style by ModphpBB3
Hosted by © 2017 FreeForums.org | Create a free forum | Powered by phpBB
A Member of the Crowdgather Forum Community
About FreeForums | Legal | Advertise Here | Investors | Contact FreeForums.org
Report Violation
suspicion-preferred