Addigy's Smart Software features provide lots of flexibility for deploying files and apps to your devices. This article provides the simplest workflow for pushing a file to your users' desktops that opens a specific URL, then this article will give you the simplest workflow.
First, download the "Addigy.webloc" file that is attached to this article. Replace the inside of <string>https://www.addigy.com</string> with your URL and rename the file to your liking. Make sure that it still has the .webloc extension to the file.
Creating the Smart Software Item
Create a Smart Software payload and upload the .webloc file. Then, copy the provided scripts into the Smart Software item to place the .webloc file on each user's desktop. Update the filename in the first line of the script to match your .webloc file.
Installation script:
|
This script is a Bash script designed to copy a .webloc
file (named Addigy.webloc
) to the desktop of all valid macOS user accounts with a UniqueID
of 500 or higher (typically standard user accounts and not system accounts). Here's a detailed summary of what it does:
Steps in the Script
-
Determine the Current Working Directory:
- It assigns the current working directory to the variable
current_path
using thepwd
command.
- It assigns the current working directory to the variable
-
Set File Name and Path:
- It specifies the file name (
Addigy.webloc
) and combines it with thecurrent_path
to create a full path to the file, stored insource_path_filename
.
- It specifies the file name (
-
Check if the Source File Exists:
- It checks if
Addigy.webloc
exists in the current directory. - If the file does not exist, the script outputs an error message and exits.
- It checks if
-
Process Each User:
- It retrieves a list of all user accounts with
UniqueID
greater than or equal to 500 usingdscl
and processes them in a loop.
- It retrieves a list of all user accounts with
-
Determine the User's Home Directory:
- For each user, it gets their
NFSHomeDirectory
(home directory path) from the macOS Directory Service (dscl
).
- For each user, it gets their
-
Check if the File Already Exists on Desktop:
- It verifies if
Addigy.webloc
already exists in the user's Desktop folder. - If it exists, the script skips further processing for that user.
- It verifies if
-
Ensure the Desktop Directory Exists:
- It checks whether the user's
Desktop
directory exists. If not, the user is skipped.
- It checks whether the user's
-
Copy the File:
- It copies
Addigy.webloc
to the user's Desktop directory using thecp
command. - If the copy fails, the script outputs an error message and skips further actions for that user.
- It copies
-
Set Ownership and Permissions:
- The ownership of the copied file is changed to the specific user (and group
staff
) usingchown
. - The file permissions are set to
644
(readable by everyone, writable only by the owner) usingchmod
.
- The ownership of the copied file is changed to the specific user (and group
-
Finish Execution:
- After processing all users, the script outputs "Script finished."
- Script Output
Conditional script:
#!/bin/bash filename="Addigy.webloc" # Your Web-bloc File Name missingUsers=() # Array to store users missing the file # Iterate through all users with UniqueID >= 500 for user in $(dscl . list /Users UniqueID | awk '$2 >= 500 {print $1}'); do userHome=$(dscl . read /Users/$user NFSHomeDirectory | awk '{print $2}') if [[ ! -e "${userHome}/Desktop/${filename}" ]]; then echo "" echo "User '${user}' does not have the desktop link for ${filename}." missingUsers+=("$user") # Add user to the missing list fi done # Check if any users were missing the file if [[ ${#missingUsers[@]} -gt 0 ]]; then echo "" echo "The following users do not have the ${filename} file:" printf '%s\n' "${missingUsers[@]}" exit 1 else echo "All users have the ${filename} file." exit 0 fi |
This Bash script is designed to check if a specific file (Addigy.webloc
) exists on the Desktop of all macOS user accounts with a UniqueID
of 500 or higher (typically regular user accounts). Here's a detailed breakdown of what it does:
Steps in the Script
-
Define the Target File:
- The variable
filename
is set toAddigy.webloc
, which is the file being checked for.
- The variable
-
Initialize an Array:
- An empty array
missingUsers
is created to store the usernames of users who do not have the file on their Desktop.
- An empty array
-
Loop Through Users:
- The script uses
dscl
(Directory Service command-line tool) to list all users with aUniqueID
>= 500. - For each user:
- Their home directory path is fetched using
dscl . read /Users/$user NFSHomeDirectory
. - It checks if the file exists on their Desktop (
${userHome}/Desktop/${filename}
).
- Their home directory path is fetched using
- The script uses
-
Check for Missing File:
- If the file is not found on the user’s Desktop:
- The script logs a message indicating the user does not have the file.
- The username is added to the
missingUsers
array.
- If the file is not found on the user’s Desktop:
-
Summarize Results:
- After looping through all users:
- If the
missingUsers
array contains any entries:- It lists all users missing the file and exits with a status code of
1
(indicating failure).
- It lists all users missing the file and exits with a status code of
- If no users are missing the file, it outputs a success message and exits with a status code of
0
(indicating success). - The condition is considered a custom condition that does not take into account the exit status of 0 as the default return. You would need to uncheck this:
- If the
- After looping through all users:
- Script Output
Final Output - Desktop:
Give your next smart software some rigorous testing, and you're good to go. Your users will now be able to access that web resource quickly and easily using the new desktop icon they have.