Skip to content

Commit

Permalink
Mac Installer: command-line installs test for existence of files /tmp…
Browse files Browse the repository at this point in the history
…/nonadminusersok.txt and /tmp/setboincsaver.txt

svn path=/trunk/boinc/; revision=22730
  • Loading branch information
Charlie Fenton committed Nov 22, 2010
1 parent c9982f9 commit c723b76
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 17 deletions.
15 changes: 15 additions & 0 deletions checkin_notes
Original file line number Diff line number Diff line change
Expand Up @@ -8246,3 +8246,18 @@ David 20 Nov 2010

sched/
start

Charlie 19 Nov 2010
- Mac Installer: It turns out that the command-line installer clears all
environment variables, so instead of checking environment variables
during command-line installs, we check for the existence of files
/tmp/nonadminusersok.txt and /tmp/setboincsaver.txt. In normal GUI
installs, these are ignored and the normal BOINC installer dialogs
are used to determine these options. See the comments at the top of
PostInstall.cpp for details of doing command-line installs on remote
Macs.

mac_installer/
PostInstall.cpp
postinstall
postupgrade
64 changes: 52 additions & 12 deletions mac_installer/PostInstall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,40 @@

/* PostInstall.cpp */

// SUPPORTED ENVIRONMENT VARIABLES:
// COMMAND_LINE_INSTALL set if running the installer from the command line;
// suppresses all dialogs. If set, the following 2
// environment variables are also recognized:
// Notes on command-line installation to a remote Mac:
//
// NONADMINUSERSOK Allow users without administrator privileges to
// run BOINC Manager
// When the installer is run from the Finder, this Postinstall.app will
// display up to two dialogs, asking the user whether or not to:
// [1] allow non-administrative users to run the BOINC Manager
// (asked only if this Mac has any non-administrative users)
// [2] set BOINC as the screensaver for all users who can run BOINC
// (asked only if BOINC screensaver is not already set for them)
//
// SETBOINCSAVER Set BOINCSaver as screensaver for all BOINC users
// The installer can also be run from the command line. This is useful
// for installation on remote Macs. However, there is no way to respond
// to dialogs during a command-line install.
//
// The command-line installer sets the following environment variable:
// COMMAND_LINE_INSTALL=1
// The postinstall script, postupgrade script, and this Postinstall.app
// detect this environment variable and do the following:
// * Redirect the Postinstall.app log output to a file
// /tmp/BOINCInstallLog.txt
// * Suppress the 2 dialogs
// * test for the existence of a file /tmp/nonadminusersok.txt; if the
// file exists, allow non-administrative users to run BOINC Manager
// * test for the existence of a file /tmp/setboincsaver.txt; if the
// file exists, set BOINC as the screensaver for all BOINC users.
//
// Example: To install on a remote Mac from the command line, allowing
// non-admin users to run the BOINC Manager and setting BOINC as the
// screensaver:
// * First SCP the "BOINC Installer.pkg" to the remote Mac's /tmp
// directory, then SSh into the remote mac and enter the following
// $ touch /tmp/nonadminusersok.txt
// $ touch /tmp/setboincsaver.txt
// $ sudo installer -pkg "/tmp/BOINC Installer.pkg" -tgt /
// $ sudo reboot
//

#define CREATE_LOG 1 /* for debugging */
Expand Down Expand Up @@ -157,11 +182,17 @@ int main(int argc, char *argv[])
receiptNameEscaped[2] = "/Library/Receipts/Progress\\ Thru\\ Processors.pkg";

::GetCurrentProcess (&ourProcess);


puts("Starting PostInstall app\n");
fflush(stdout);
// getlogin() gives unreliable results under OS 10.6.2, so use environment
strncpy(loginName, getenv("USER"), sizeof(loginName)-1);
printf("login name = %s\n", loginName);

if (getenv("COMMAND_LINE_INSTALL") != NULL) {
gCommandLineInstall = true;
puts("command-line install\n");
fflush(stdout);
}

err = Gestalt(gestaltSystemVersion, &OSVersion);
Expand Down Expand Up @@ -343,6 +374,7 @@ int main(int argc, char *argv[])

#ifdef SANDBOX
err = CheckLogoutRequirement(&finalInstallAction);
printf("CheckLogoutRequirement returned %d\n", finalInstallAction);

if (finalInstallAction == launchWhenDone) {
// Wait for BOINC's RPC socket address to become available to user boinc_master, in
Expand Down Expand Up @@ -473,7 +505,6 @@ int DeleteReceipt()

Initialize();
err = CheckLogoutRequirement(&finalInstallAction);

err = FindProcess ('APPL', 'xins', &installerPSN);
if (err == noErr)
err = GetProcessPID(&installerPSN , &installerPID);
Expand Down Expand Up @@ -552,7 +583,7 @@ OSStatus CheckLogoutRequirement(int *finalAction)
++i;
}
}

printf("In CheckLogoutRequirement: isMember=%d, currentUserCanRunBOINC=%d\n", (int)isMember, (int)currentUserCanRunBOINC);
if (!isMember && !currentUserCanRunBOINC) {
*finalAction = nothingrequired;
return noErr;
Expand Down Expand Up @@ -939,6 +970,7 @@ OSErr UpdateAllVisibleUsers(long brandID)
FILE *f;
OSStatus err;
Boolean isGroupMember;
struct stat sbuf;
#ifdef SANDBOX
char *p;
short i;
Expand Down Expand Up @@ -1064,7 +1096,11 @@ OSErr UpdateAllVisibleUsers(long brandID)
puts("[2] All non-admin users are already members of group boinc_master\n");
} else {
if (gCommandLineInstall) {
if (getenv("NONADMINUSERSOK") != NULL) {
err = stat("/tmp/nonadminusersok.txt", &sbuf);
if (err == noErr) {
puts("nonadminusersok.txt file detected\n");
fflush(stdout);
unlink("/tmp/nonadminusersok.txt");
allowNonAdminUsersToRunBOINC = true;
currentUserCanRunBOINC = true;
saverAlreadySetForAll = false;
Expand All @@ -1088,7 +1124,11 @@ OSErr UpdateAllVisibleUsers(long brandID)

if (! saverAlreadySetForAll) {
if (gCommandLineInstall) {
if (getenv("SETBOINCSAVER") != NULL) {
err = stat("/tmp/setboincsaver.txt", &sbuf);
if (err == noErr) {
puts("setboincsaver.txt file detected\n");
fflush(stdout);
unlink("/tmp/setboincsaver.txt");
setSaverForAllUsers = true;
}
} else {
Expand Down
11 changes: 8 additions & 3 deletions mac_installer/postinstall
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

##
# post-Install Script for Macintosh BOINC Manager for OS X revised 2/10/10
# post-Install Script for Macintosh BOINC Manager for OS X revised 11/22/10
##

echo "initial directory = $PWD"
Expand All @@ -17,9 +17,14 @@ if [ -f "Contents/Resources/acct_mgr_url.xml" ]; then
cp -fp Contents/Resources/acct_mgr_url.xml "/Library/Application Support/BOINC Data/acct_mgr_url.xml"
fi

# Run the Postinstall Application
Run the Postinstall Application
if [ "${COMMAND_LINE_INSTALL}" = "1" ]; then
rm -f /tmp/BOINCInstallLog.txt
Contents/Resources/PostInstall.app/Contents/MacOS/PostInstall -part1 >> /tmp/BOINCInstallLog.txt
Contents/Resources/PostInstall.app/Contents/MacOS/PostInstall -part2 & >> /tmp/BOINCInstallLog.txt
else
Contents/Resources/PostInstall.app/Contents/MacOS/PostInstall -part1

Contents/Resources/PostInstall.app/Contents/MacOS/PostInstall -part2 &
fi

exit 0
9 changes: 7 additions & 2 deletions mac_installer/postupgrade
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

##
# post-Upgrade Script for Macintosh BOINC Manager for OS X revised 2/10/10
# post-Upgrade Script for Macintosh BOINC Manager for OS X revised 11/22/10
##

echo "initial directory = $PWD"
Expand All @@ -18,8 +18,13 @@ if [ -f "Contents/Resources/acct_mgr_url.xml" ]; then
fi

# Run the Postinstall Application
if [ "${COMMAND_LINE_INSTALL}" = "1" ]; then
rm -f /tmp/BOINCInstallLog.txt
Contents/Resources/PostInstall.app/Contents/MacOS/PostInstall -part1 >> /tmp/BOINCInstallLog.txt
Contents/Resources/PostInstall.app/Contents/MacOS/PostInstall -part2 & >> /tmp/BOINCInstallLog.txt
else
Contents/Resources/PostInstall.app/Contents/MacOS/PostInstall -part1

Contents/Resources/PostInstall.app/Contents/MacOS/PostInstall -part2 &
fi

exit 0

0 comments on commit c723b76

Please sign in to comment.