I have finally decided what will happen with Porteus Settings Assistant, now that the final version made it into Porteus 1.0.
Now that the Google Code page for porteus-settings-assistant is pending deletion, I will share my
last reiteration of Porteus Settings Assistant (
2.0) to Hamza. From there, any modifications that anyone in the Porteus Team want to do will be handled by him and the Porteus community, and I will quit all work on the program. My work after fixing the 1.0 version is done, as I accomplished what I set out to do--give Porteus a setup tool, which it now does in 1.0.
I believe this is for the best of the Porteus Team, so all can share, rather than me holding rights to it. Also, I'm not planning on 2.0 being nothing more than fixes of the flopped 1.0. I'm not planning on it being a release that will leap forward with a heap of features.
@fanthom: Thank you so much for fixing the bugs in 1.0 that I had left un-repaired, and also for your encouragement.
-----------------------------------------------------------------------------------------------------------------------------------------
With this said, I have submitted 2.0 (based on 1.1, actually, rather than the 1.0 version) to Hamza over e-mail.
Thank you for allowing me to be a part of this project. I'm glad to have accomplished my mission of making it a reality, and I'm glad it made it into 1.1. I will now completely turn over Porteus Settings Assistant to the Porteus community through Hamza, so that the whole community can benefit from it. My work on it is done. Thank you all you for encouragement, testing of the project, patience, and honesty.
Here is the full code, if Hamza does not distribute the script from here. To run, copy the source, open a shell, type either "kwrite /opt/porteus-scripts/xporteus-settings-assistant" or leafpad (same path), select all, paste and save it, and finally after closing the editor, do a chmod +x on the file. For those looking for the license, it falls under the same terms as Porteus itself, and as such, the license can be found in the porteus folder on the live media.
Code: Select all
#!/bin/bash
#
# This shell script program welcomes new users to the
# Porteus operating system.
#
# Copyright (C) 2011 Porteus Community
# Last modified 23:59 at 6/27/2011
#
# Contributors: fanthom, Hamza, agreimann
#
# 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 3 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, see
# <http://www.gnu.org/licenses/>.
# Change to the root user if necessary once Porteus Settings Assistant is ready to run
if [ "$DISPLAY" ]; then
if [ `whoami` != "root" ]; then
# Add dialog box so that the user is aware of what is happening
Xdialog --title "Password required" --left --icon /opt/porteus-scripts/icons/exclamation-red-48.png --cancel-label "Close window" --ok-label "Continue" --yesno "Password required\n____________________________________________________________\n\nClick OK, then type in your password in the window that appears,\nand press enter to continue. This ensures that you are running\nthis application." 20 110
su - -c "/opt/porteus-scripts/xporteus-settings-assistant `whoami`" || sleep 1
exit
fi
else
echo "--------------------------------------------------------------------------"
echo "Error"
echo "--------------------------------------------------------------------------"
echo "(x) To run Porteus Settings Assistant, you must start X first. Type startx,"
echo " then try again. This application will now quit."
echo "--------------------------------------------------------------------------"
exit
fi
# Check if the script was run by a normal user
if [ "$1" ]; then pth=/home/$1; else pth=/root; fi
wrk=/tmp/PSA
[ -d $wrk ] && rm -r $wrk
mkdir $wrk
. /usr/lib/macroport
choice() {
Xdialog --title "Jump to an option" --ok-label "Jump" --cancel-label "Don't jump now" --no-tags --icon=/opt/porteus-scripts/icons/step-panelette.png --left --menubox "Pick an option to leap forward to it\nwithout having to go through to other steps of\nthe application." 30 80 0 \
1 "Connect to the Internet" 2 "Turn on the firewall" 3 "Name this computer" 4 "Change password" 5 "Set up changes" 6 "Set language" 7 "Apply changes" 2> /tmp/.ans
[ $? -ne 0 ] && panelette
ans=`cat /tmp/.ans` && rm /tmp/.ans 2>/dev/null
case $ans in
1 )
wicd-gtk --no-tray >/dev/null 2>&1 && choice
;;
2 )
enable_firewall && choice
;;
3 )
enter_hostname && choice
;;
4 )
change_password && choice
;;
5 )
/tmp/.terminal -e make-changes.sh && choice
;;
6 )
[ "$1" ] && { su --login $1 -c '/tmp/.terminal -e "/opt/porteus-scripts/xlanguage-selection-tool"' && choice; } || { /tmp/.terminal -e "/opt/porteus-scripts/xlanguage-selection-tool" && choice; }
;;
7 )
create_module
;;
* )
choice
esac
}
enable_firewall() {
mkdir -p $wrk/etc/rc.d/rc3.d
cat >> /etc/rc.d/rc3.d/S-firewall << EOF
#!/bin/sh
# Enable Porteus firewall
if [ -x /etc/rc.d/rc.FireWall ]; then
/etc/rc.d/rc.FireWall start
fi
EOF
chmod +x /etc/rc.d/rc3.d/S-firewall
cp /etc/rc.d/rc3.d/S-firewall $wrk/etc/rc.d/rc3.d
/etc/rc.d/rc.FireWall start
message "Porteus has now turned on the firewall."
}
enter_hostname() {
mkdir -p $wrk/etc
input "Enter a new name for this computer:"
NAM=${ANSW}
echo "$NAM" > /etc/HOSTNAME
hostname -F /etc/HOSTNAME
cp /etc/HOSTNAME $wrk/etc
message "Porteus has changed the name of this computer to $NAM."
}
change_password() {
/tmp/.terminal -e "su -c 'passwd root; echo; passwd guest'" && mkdir -p $wrk/etc && cp /etc/shadow $wrk/etc/shadow
}
welcome() {
# Start initial welcome
Xdialog --title "Welcome" --ok-label "Get started" --cancel "Later" --left --icon /opt/porteus-scripts/icons/welcome_step.png --yesno "Welcome to Porteus!\n_____________________________________________________________\n \nPorteus will ask you a few questions to help you set up your computer.\nThis process should only take a few minutes.\n \n(Note: you can also pick a step after pressing 'Get started'.)\n\nWould you like to get started now?" 20 110
# Set up button code variable
# This explains to the dialog what to do
clickchoice=$?
case $clickchoice in
0) panelette;;
1) exit;
esac
}
panelette() {
# Set up changes
Xdialog --title "Jump to a step" --ok-label "Continue" --cancel "Pick a step" --left --icon /opt/porteus-scripts/icons/step-panelette.png --yesno "Jump to a step\n_____________________________________________________________\n \nIf you have run Settings Assistant before, it may be helpful to jump\nto a step, rather than to have to go through all the steps again.\n \nWould you like to continue setting up your computer or close this\nwindow and pick a step yourself?" 20 110
# Set up button code variable
# This explains to the dialog what to do
clickchoice=$?
case $clickchoice in
0) internet;;
1) choice;;
255) exit;
esac
}
internet() {
# Help configure the wireless connection
Xdialog --title "Connect to the Internet" --ok-label "Help me connect" --cancel "Skip this step" --left --icon /opt/porteus-scripts/icons/step1-internet.png --yesno "Step 1/6: Connect to the Internet\n_____________________________________________________________\n \nIf you're using a wired connection, you may already be connected.\n \nHowever, to allow Porteus to connect using a wireless connection,\nyou may need to enter wireless settings.\n \nOnce you click 'Help me connect', Porteus will automatically open\nwireless settings, where you can tell Porteus how you connect to\nthe Internet.\n \nWhen you're finished connecting, close the window, after\nwhich Porteus will continue helping you set your computer up." 27 110
# Set up button code variable
# This explains to the dialog what to do
clickchoice=$?
case $clickchoice in
0) wicd-gtk --no-tray >/dev/null 2>&1 && firewall;;
1) firewall;;
255) exit;
esac
}
firewall() {
# Explain users
Xdialog --title "Turn on firewall" --ok-label "Turn on firewall" --cancel "Leave firewall off" --left --icon /opt/porteus-scripts/icons/step3-firewall.png --yesno "Step 2/6: Turn on the firewall\n_____________________________________________________________\n \nBy default, Porteus does not enable the firewall when it starts up.\nKeeping a firewall on is one of the ways that you can help keep\nPorteus secure from serious outside attacks when you are\nconnected to the Internet. Do you want to turn on the firewall\nnow?" 27 110
# Set up button code variable
# This explains to the dialog what to do
clickchoice=$?
case $clickchoice in
0) enable_firewall && host_name;;
1) host_name;;
255) exit;
esac
}
host_name() {
# Roll out hostname box
Xdialog --title "Give your computer a name" --ok-label "Name this computer" --cancel "Skip this step" --left --icon /opt/porteus-scripts/icons/step4-hostname.png --yesno "Step 3/6: Name this computer\n_____________________________________________________________\n \nPorteus automatically names your computer, though this may not\nbe what you need to name this computer on the network.\n \nAfter clicking 'Name this computer', a window will pop up. Type in a name, save it, and close it." 27 110
# Set up button code variable
# This explains to the dialog what to do
clickchoice=$?
case $clickchoice in
0) enter_hostname && password;;
1) password;;
255) exit;
esac
}
password() {
# Set new passwords
Xdialog --title "Help keep your PC secure" --ok-label "Change passwords now" --cancel "Don't change passwords" --left --icon /opt/porteus-scripts/icons/step5-password.png --yesno "Step 4/6: Help keep your PC secure\n_____________________________________________________________\n \nPorteus by default has two account levels on the system--root and\nyour account.\n \nYour account is at guest level--it is the one you will use every time.\nThe root or system administrator account allows you to change\nsystem-wide settings, and is much more powerful.\n \nFor these reasons, it is strongly recommended to change the root\npassword from toor, and to set a password for yourself. It is also\nrecommended that the root password be increasingly different and\nstronger than your password.\n \nWould you like you change passwords now?" 27 110
# Set up button code variable
# This explains to the dialog what to do
clickchoice=$?
case $clickchoice in
0) change_password && changes;;
1) changes;;
255) exit;
esac
}
changes() {
# Set up changes
Xdialog --title "Set up changes" --ok-label "Yes, set up changes" --cancel "No, skip this step" --left --icon /opt/porteus-scripts/icons/step-changes.png --yesno "Step 5/6: Set up changes\n_____________________________________________________________\n \nWhen you save a file or change a setting, Porteus remembers it only\nuntil you restart or shut down.\n \nWould you like Porteus to keep changes even after you shut down and restart?" 20 110
# Set up button code variable
# This explains to the dialog what to do
clickchoice=$?
case $clickchoice in
0) /tmp/.terminal -e make-changes.sh && language;;
1) language;;
255) exit;
esac
}
language() {
# Set language
Xdialog --title "Set language" --ok-label "Pick my language" --cancel "Skip this step" --left --icon /opt/porteus-scripts/icons/step2-language.png --yesno "Step 6/6: What language do you speak?\n_____________________________________________________________\n \nPorteus can help you set the language you speak from the default\nEnglish.\n \nClick 'Pick my language' to open Language Settings to set your\nlanguage." 20 110
# Set up button code variable
# This explains to the dialog what to do
clickchoice=$?
case $clickchoice in
0) [ "$1" ] && { su --login $1 -c '/tmp/.terminal -e "xlanguage-selection-tool"' && complete; } || { /tmp/.terminal -e "xlanguage-selection-tool" && complete; };;
1) complete;;
255) exit;
esac
}
complete() {
# Finish
Xdialog --title "Settings Assistant Complete" --ok-label "Finish" --cancel "Restart" --left --icon /opt/porteus-scripts/icons/tick-green.png --yesno "Thank you for your time. That's it!\n_____________________________________________________________\n \nPorteus will now apply these settings so that next time you restart,\nyou will be able to work more efficiently. Click Finish to close, and\nenjoy Porteus.\n \nWe hope that you like the work we've put into making this release\ngreat." 20 110
# Set up button code variable
# This explains to the dialog what to do
clickchoice=$?
case $clickchoice in
0) create_module;;
1) /tmp/terminal -e "su -c reboot";
esac
}
create_module() {
module=`find $wrk | wc -l`
if [ "$module" -gt 1 ]; then
moddir=`awk 'c-->0;/Porteus data found in/{c=1}' /mnt/live/var/log/livedbg`
touch $moddir/_test 2>/dev/null && rm $moddir/_test
if [ $? -eq 0 ]; then
rm $moddir/modules/settings.xzm 2>/dev/null
dir2xzm $wrk $moddir/modules/settings.xzm >/dev/null 2>&1
message "Your new settings have been saved to $moddir/modules/settings.xzm."
exit
else
message "$moddir/modules is on a read-only filesystem.\nYour settings could not be saved in the location you selected.\nPorteus is attempting to save changes to your desktop..."
rm $pth/Desktop/PSA-settings.xzm 2> /dev/null; dir2xzm $wrk $pth/Desktop/PSA-settings.xzm >/dev/null
message "Your settings have been alternatively saved to $pth/Desktop/PSA-settings.xzm.\nPlease move this module to the porteus/modules folder and restart Porteus for changes to take effect."
exit
fi
else
infobox "No settings were specified. Settings Assistant is closing..." 2000
exit
fi
}
welcome && create_module
Regards,