Skip to content

Instantly share code, notes, and snippets.

@benspaulding
Last active April 7, 2020 16:19
Show Gist options
  • Save benspaulding/5b4b62ed7a5fa6f52a5e05b3b5b9a1ba to your computer and use it in GitHub Desktop.
Save benspaulding/5b4b62ed7a5fa6f52a5e05b3b5b9a1ba to your computer and use it in GitHub Desktop.
macOS LoginHook to make Istation.app use the user cache

Istation.app Cache Fix

Date: 07 April 2020
license:BSD-3-Clause

Currently the student/school application Istation.app (version 2.5 at the time of writing) uses the system-level cache (/Library/Caches) to store user data. This means that a computer with two accounts where the users attend different schools have to reconfigure the app every time they use it.

This script can be wired up as a macOS LoginHook to make it use the user cache (~/Library/Caches) to save that constant reconfiguration.

Usage

Note

This script will delete the files at /Library/Caches/com.istation.isapp. That should not be a problem as they are temporary files. If for some reason you don't like that, modify the script or save them beforehand.

  1. Place script, somewhere like /Library/Scripts/istation-fix

  2. Ensure script has executable permissions by all users:

    sudo chown root:admin /Library/Scripts/istation-fix
    sudo chmod 755 /Library/Scripts/istation-fix
  3. Install it as a LoginHook:

    sudo defaults write com.apple.loginwindow LoginHook /Library/Scripts/istation-fix

Now the script will run any time a user logs in.

Note

Two users should not have the Istation.app open at the same time, which is possible if using macOS fast-user switching.

Removal

sudo defaults delete com.apple.loginwindow LoginHook
sudo rm /Library/Scripts/istation-fix
#!/bin/bash
user="$1"
home="/Users/$user"
idir="/Library/Caches/com.istation.isapp"
udir="$home$idir"
# Ensure the user-level cache directory exists
mkdir -vp "$udir"
chown -vR "$user:staff" "$udir"
# Remove the system-level cache directory
rm -vrf "$idir"
# Symlink the system-level to the user-level
ln -vs "$udir" "$idir"
chown -vh "root:admin" "$idir"
BSD 3-Clause License
Copyright (c) 2020, Ben Spaulding
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment