-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1f79f56
commit d42e9eb
Showing
3 changed files
with
54 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/usr/bin/env zsh | ||
|
||
export SNAPLIST_FILE="$DOTFILES_DIR/snap/Snaplist" | ||
|
||
function dump_snap_dependencies() { | ||
# Check if snap command is available | ||
if ! command -v snap &>/dev/null; then | ||
echo "Snap is not installed. Exiting." | ||
return 1 | ||
fi | ||
# Dump installed snaps to Snaplist excluding 'snapd' | ||
snap list | awk '{if(NR>1 && $1 != "snapd") print $1}' >"$SNAPLIST_FILE" | ||
# Check if the file was created and has content | ||
if [ -s "$SNAPLIST_FILE" ]; then | ||
echo "Snap dependencies have been dumped to $SNAPLIST_FILE." | ||
else | ||
echo "Failed to dump Snap dependencies or no snaps are installed." | ||
return 1 | ||
fi | ||
} | ||
|
||
function is_snap_installed() { | ||
if command -v snap >/dev/null; then | ||
return 0 # Snap is installed | ||
else | ||
return 1 # Snap is not installed | ||
fi | ||
} | ||
|
||
function install_snaps_from_list() { | ||
# Check if the Snaplist file exists | ||
if [ ! -f "$SNAPLIST_FILE" ]; then | ||
echo "$SNAPLIST_FILE does not exist. Please make sure the file is in the current directory." | ||
return 1 | ||
fi | ||
# Check if snap command is available | ||
if ! command -v snap &>/dev/null; then | ||
echo "Snap is not installed. Please install snapd first." | ||
return 1 | ||
fi | ||
# Read from the Snaplist file and install each snap | ||
while IFS= read -r snap; do | ||
if [ -n "$snap" ]; then # Check if the line is not empty | ||
echo "Installing $snap..." | ||
sudo snap install "$snap" | ||
fi | ||
done <"$SNAPLIST_FILE" | ||
echo "All snaps from $SNAPLIST_FILE have been processed." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters