Home page > OS X Portable Applications > Portable OpenOffice.org OS X script source code
Source code index | Portable OpenOffice.org OS X script code:
Shell Script 2.0.1 (Release 1.0)
Portable OpenOffice.org 2.0.X.app is packaged using the Platypus script wrapper from http://sveinbjorn.sytes.net/platypus
#!/bin/sh
# Portable OpenOffice.org 2.0
# Copyright (c) 2006
# Carlo Gandolfi - http://www.freesmug.org
# Paolo Portaluri - http://plus2.it/~paolo/
#
# 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 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.
appid="OpenOffice.org 2.0"
appbin=soffice.bin
here="`dirname \"$0\"`"
cd "$here"
# ========================================================
# quitapp
# Check if local app is open and quit it
# ========================================================
function quitapp {
if ps cx | grep '[0-9] '$appbin'$'; then
message1="A copy $appid is already running. Do you want to kill the running application and open Portable $appid instead?"
button=`/usr/bin/osascript << EOT
tell application "Finder"
beep
display dialog "$message1" buttons {"Cancel", "Continue"} with title "Quit Running $appid" with icon caution default button "Continue"
set result to button returned of result
end tell
EOT`
if test "$button" == "Continue"; then # Quit local application
# osascript -e 'tell app "'$appbin'" to quit'
killall -9 $appbin
else
exit 0
fi
fi
}
# ========================================================
# check_asf
# Check if Application Support Foder exist
# ========================================================
function check_asf {
if [ -d "$here/../../../app/Home/openoffice.org2" ]; then
rm -rf "$here/../../../app/Home/openoffice.org2"
else
mkdir -p "$here/../../../app/Home/"
fi
}
# ========================================================
# copy_local_pref
# Copy local preferences to Portable Application
# ========================================================
# copy Preferences Folder
function copy_pf {
PFpath=~/.openoffice.org2/
PFsize=`du -hc "$PFpath" | cut -f1 | tail -1`
message4="Your $appid.1 Preferences folder is $PFsize. Copy it to Portable $appid.1?"
button=`/usr/bin/osascript << EOT
tell application "Finder"
beep
display dialog "$message4" buttons {"Copy", "Cancel"} with title "Copy $appid.1 Preferences Folder" with icon note default button "Cancel"
set result to button returned of result
end tell
EOT`
if test "$button" == "Copy"; then
check_asf
cp -fR ~/.openoffice.org2 "$here/../../../app/Home/openoffice.org2"
defaults write "$here/../../../Portable $appid.1.app/Contents/info" "LSEnvironment" '{"APP_BUNDLER" = "Platypus-3.3"; "COPY_PREF" = "No"; }';
fi
}
function copy_local_pref {
if defaults read "$here/../../../Portable $appid.1.app/Contents/info" "LSEnvironment" | grep Yes && test -d ~/.openoffice.org2/; then
message="Copy the existing $appid.1 preferences on this system to Portable $appid.1?"
button=`/usr/bin/osascript << EOT
tell application "Finder"
beep
display dialog "$message" buttons {"Never", "Copy", "Don't Copy"} with title "Copy Preferences" with icon note default button "Don't Copy"
set result to button returned of result
end tell
EOT`
if test "$button" == "Copy"; then
copy_pf
elif test "$button" == "Never"; then
defaults write "$here/../../../Portable $appid.1.app/Contents/info" "LSEnvironment" '{"APP_BUNDLER" = "Platypus-3.3"; "COPY_PREF" = "No"; }';
# elif test "$button" == "Don't Copy" # Old preferences are overwritten.
fi
fi
}
# ========================================================
# bu/recover
# BackUp existing preference and restore portable ones
# ========================================================
function bu_pref {
mv "$here/../../../app/OpenOffice.org 2.0.app/Contents/openoffice.org2.0/program/bootstraprc" "$here/../../../app/OpenOffice.org 2.0.app/Contents/openoffice.org2.0/program/bootstraprc.pabu"
}
function recover_pref {
mv "$here/../../../app/OpenOffice.org 2.0.app/Contents/openoffice.org2.0/program/bootstraprc.pabu" "$here/../../../app/OpenOffice.org 2.0.app/Contents/openoffice.org2.0/program/bootstraprc"
}
# ========================================================
# run
# Open Portable Application
# ========================================================
function run_app {
# Running '$appid' from '$here'."
cp -f "$here/bootstraprc.portable" \
"$here/../../../app/OpenOffice.org 2.0.app/Contents/openoffice.org2.0/program/bootstraprc"
"$here/../../../app/OpenOffice.org 2.0.app/Contents/MacOS/droplet"
}
# ========================================================
# open_p_app
# Run Portable Application script
# ========================================================
function open_p_app {
bu_pref # Backup of existing preference
run_app # Run application from external drive
recover_pref # Restore existing preference
}
quitapp
copy_local_pref
open_p_app
bootstraprc.portable (2.0.1) file:
[Bootstrap]
BaseInstallation=$ORIGIN/..
ProductKey=OpenOffice.org 2.0
InstallMode=<installmode>
UserInstallation=$ORIGIN/../../../../Home/openoffice.org2
[ErrorReport]
ErrorReportPort=80
ErrorReportServer=
Shell script 2.0.2 (Release 1.0)
#!/bin/sh
# Portable OpenOffice.org 2.0.2 OSX
# Copyright (c) 2006
# Carlo Gandolfi - http://www.freesmug.org
# Paolo Portaluri - http://plus2.it/~paolo/
#
# 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 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.
appid="OpenOffice.org 2.0"
appbin=soffice.bin
here="`dirname \"$0\"`"
cd "$here"
# ========================================================
# quitapp
# Check if local app is open and quit it
# ========================================================
function quitapp {
if ps cx | grep '[0-9] '$appbin'$'; then
message1="A copy $appid is already running. Do you want to kill the running application and open Portable $appid instead?"
button=`/usr/bin/osascript << EOT
tell application "Finder"
beep
display dialog "$message1" buttons {"Cancel", "Continue"} with title "Quit Running $appid" with icon caution default button "Continue"
set result to button returned of result
end tell
EOT`
if test "$button" == "Continue"; then # Quit local application
# osascript -e 'tell app "'$appbin'" to quit'
killall -9 $appbin
else
exit 0
fi
fi
}
# ========================================================
# check_asf
# Check if Application Support Foder exist
# ========================================================
function check_asf {
if [ -d "$here/../../../app/Library/Applicaton Support/OpenOffice.org 2.0" ]; then
rm -rf "$here/../../../app/Library/Applicaton Support/OpenOffice.org 2.0"
else
mkdir -p "$here/../../../app/Library/Applicaton Support/"
fi
}
# ========================================================
# copy_local_pref
# Copy local preferences to Portable Application
# ========================================================
# copy Preferences Folder
function copy_pf {
PFpath=~/Library/Application\ Support/OpenOffice.org\ 2.0/
PFsize=`du -hc "$PFpath" | cut -f1 | tail -1`
message4="Your $appid.2 Preferences folder is $PFsize. Copy it to Portable $appid.2?"
button=`/usr/bin/osascript << EOT
tell application "Finder"
beep
display dialog "$message4" buttons {"Copy", "Cancel"} with title "Copy $appid.2 Preferences Folder" with icon note default button "Cancel"
set result to button returned of result
end tell
EOT`
if test "$button" == "Copy"; then
check_asf
cp -fR ~/Library/Application\ Support/OpenOffice.org\ 2.0/ "$here/../../../app/Library/Applicaton Support/OpenOffice.org 2.0"
defaults write "$here/../../../Portable $appid.2.app/Contents/info" "LSEnvironment" '{"APP_BUNDLER" = "Platypus-3.3"; "COPY_PREF" = "No"; }';
fi
}
function copy_local_pref {
if defaults read "$here/../../../Portable $appid.2.app/Contents/info" "LSEnvironment" | grep Yes && test -d ~/Library/Application\ Support/OpenOffice.org\ 2.0; then
message="Copy the existing $appid.2 preferences on this system to Portable $appid.2?"
button=`/usr/bin/osascript << EOT
tell application "Finder"
beep
display dialog "$message" buttons {"Never", "Copy", "Don't Copy"} with title "Copy Preferences" with icon note default button "Don't Copy"
set result to button returned of result
end tell
EOT`
if test "$button" == "Copy"; then
copy_pf
elif test "$button" == "Never"; then
defaults write "$here/../../../Portable $appid.2.app/Contents/info" "LSEnvironment" '{"APP_BUNDLER" = "Platypus-3.3"; "COPY_PREF" = "No"; }';
# elif test "$button" == "Don't Copy" # Old preferences are overwritten.
fi
fi
}
# ========================================================
# bu/recover
# BackUp existing preference and restore portable ones
# ========================================================
function bu_pref {
mv "$here/../../../app/OpenOffice.org 2.0.app/Contents/MacOS/program/bootstraprc" "$here/../../../app/OpenOffice.org 2.0.app/Contents/MacOS/program/bootstraprc.pabu"
}
function recover_pref {
mv "$here/../../../app/OpenOffice.org 2.0.app/Contents/MacOS/program/bootstraprc.pabu" "$here/../../../app/OpenOffice.org 2.0.app/Contents/MacOS/program/bootstraprc"
}
# ========================================================
# run
# Open Portable Application
# ========================================================
function run_app {
# Running '$appid' from '$here'."
cp -f "$here/bootstraprc2.0.2.portable" \
"$here/../../../app/OpenOffice.org 2.0.app/Contents/MacOS/program/bootstraprc"
"$here/../../../app/OpenOffice.org 2.0.app/Contents/MacOS/droplet"
}
# ========================================================
# open_p_app
# Run Portable Application script
# ========================================================
function open_p_app {
bu_pref # Backup of existing preference
run_app # Run application from external drive
recover_pref # Restore existing preference
}
quitapp
copy_local_pref
open_p_app
bootstraprc2.0.2.portable file:
[Bootstrap]
BaseInstallation=$ORIGIN/..
ProductKey=OpenOffice.org 2.0
InstallMode=<installmode>
UserInstallation=$ORIGIN/../../../../Library/Applicaton%20Support/OpenOffice.org%202.0
[ErrorReport]
ErrorReportPort=80
ErrorReportServer=
EOF