-
Notifications
You must be signed in to change notification settings - Fork 0
/
1password_fix
executable file
·179 lines (156 loc) · 7.59 KB
/
1password_fix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
#!/bin/bash
#
# @author Zeus Intuivo <[email protected]>
#
#
#
CURRENTWORKINGDIR=$(pwd)
load_struct_testing_wget(){
local provider="$HOME/_/clis/execute_command_intuivo_cli/struct_testing"
[ -e "${provider}" ] && source "${provider}"
[ ! -e "${provider}" ] && eval """$(wget --quiet --no-check-certificate https://raw.githubusercontent.com/zeusintuivo/execute_command_intuivo_cli/master/struct_testing -O - 2>/dev/null )""" # suppress only wget download messages, but keep wget output for variable
( ( ! command -v passed >/dev/null 2>&1; ) && echo -e "\n \n ERROR! Loading struct_testing \n \n " && exit 69; )
} # end load_struct_testing_wget
load_struct_testing_wget
load_execute_command_wget(){
local provider="$HOME/_/clis/execute_command_intuivo_cli/execute_command"
[ -e "${provider}" ] && source "${provider}"
[ ! -e "${provider}" ] && eval """$(wget --quiet --no-check-certificate https://raw.githubusercontent.com/zeusintuivo/execute_command_intuivo_cli/master/execute_command -O - 2>/dev/null )""" # suppress only wget download messages, but keep wget output for variable
( ( ! command -v passed >/dev/null 2>&1; ) && echo -e "\n \n ERROR! Loading execute_command \n \n " && exit 69; )
} # end load_execute_command_wget
load_execute_command_wget
softlink_create_source_target() {
local source="${1}"
local target="${2}"
anounce About to do patch NativeMessagingHosts
anounce_command pwd
local plus_slash="""${target}/"""
ensure_unlink "${source}"
directory_exists_with_spaces "${target}"
does_not_exist_with_spaces "${source}"
ln -s """${plus_slash}""" "${source}"
anounce 0. Check that Google_Chrome.app exists
if [ ! -e /Applications/Google_Chrome.app ] ; then
{
ln -s "/Applications/Google\ Chrome.app" /Applications/Google_Chrome.app
}
fi
anounce 1. Check that Google_Chrome.app / Contents/Profile/NativeMessagingHosts
if [ ! -e /Applications/Google_Chrome.app/Contents/Profile/NativeMessagingHosts ] ; then
{
ln -s /Users/administrator/Library/ApplicationSupport/Google/Chrome/NativeMessagingHosts /Applications/Google_Chrome.app/Contents/Profile/NativeMessagingHosts
}
fi
anounce 2. Confirm softlink "/Applications/Google Chrome.app/Contents/Profile/NativeMessagingHosts"
anounce 3. Confirm softlink "${source}>${plus_slash}"
#softlink_exists_with_spaces "${source}>${plus_slash}"
}
ensure_link_patched_slashed() {
local source="${*}"
anounce_command pwd
local plus_slash="""${source}/"""
local patched=$(switch_spaces_to_underscores <<< "${source}")
Comment 1. . . . source:"${source} becomes"
Comment 2. . plus_slash:"${plus_slash} becomes"
Comment 3. . . .patched:"${patched}"
ensure_unlink "${patched}"
directory_exists_with_spaces "${source}"
does_not_exist_with_spaces "${patched}"
ln -s """${plus_slash}""" "${patched}"
softlink_exists_with_spaces "${patched}"
#softlink_exists_with_spaces "${patched}>${plus_slash}"
}
patch_chrome_alone_fix() {
anounce patch_chrome_alone_fix About to do 2 things:
anounce 0. Patch Horrible Google Spaced Folder
anounce 1. Chrome Fail and fix
anounce 2. Followup Complete Coherence Fix:
anounce - start -
say 0. Patch Horrible Google Spaced Folder
anounce cd /Applications
cd /Applications
local GOOGLEPATH="Google Chrome.app"
local GOOGLEPATHPATCHED=$(switch_spaces_to_underscores <<< "${GOOGLEPATH}")
#ensure_link_patched_slashed "${GOOGLEPATH}"
directory_exists_with_spaces "/Applications/${GOOGLEPATH}"
softlink_exists "/Applications/${GOOGLEPATHPATCHED}"
anounce_command ls -la /Applications/ | grep Goo
say 1. Chrome Fail and fix --
local GOOGLECONTENTSPATHPATCHED="/Applications/${GOOGLEPATHPATCHED}/Contents"
say Then I created the folder using sudo:
sudo ensure_rmdir "${GOOGLECONTENTSPATHPATCHED}/Profile"
anounce_command ls -la "${GOOGLECONTENTSPATHPATCHED}"
echo "#\n" | anounce_command sudo mkdir "${GOOGLECONTENTSPATHPATCHED}/Profile"
echo "#\n" | sudo chown -R ${USER} "${GOOGLECONTENTSPATHPATCHED}/Profile"
anounce_command ls -la "${GOOGLECONTENTSPATHPATCHED}"
directory_exists "${GOOGLECONTENTSPATHPATCHED}/Profile"
directory_exists_with_spaces $(realpath "${GOOGLECONTENTSPATHPATCHED}/Profile") # updated realpath macos 20210902
local GOOGLEPROFILEPATCHED="${GOOGLECONTENTSPATHPATCHED}/Profile"
local GOOGLE_NATIVE_PATCHED="${GOOGLEPROFILEPATCHED}/NativeMessagingHosts"
directory_exists_with_spaces "${GOOGLEPROFILEPATCHED}"
# does_not_exist_with_spaces "${GOOGLE_NATIVE_PATCHED}"
say Then I create the softlink using sudo:
say 1.1. Patch Application Support Spaced Folder
anounce cd "${HOME}/Library"
cd "${HOME}/Library"
#ensure_link_patched_slashed "Application Support"
anounce_command pwd
softlink_exists "${APP_SUPPORT_PATCHED}"
directory_exists_with_spaces "${HOME}/Library/Application Support/Google/Chrome/NativeMessagingHosts"
directory_exists "${NATIVE_SUPPORT_PATCHED}"
softlink_create_source_target "${GOOGLE_NATIVE_PATCHED} ${NATIVE_SUPPORT_PATCHED}"
if [ ! -e /Applications/Google_Chrome.app ] ; then
{
ln -s "/Applications/Google\ Chrome.app" /Applications/Google_Chrome.app
}
fi
if [ ! -e /Applications/Google_Chrome.app/Contents/Profile/NativeMessagingHosts ] ; then
{
ln -s /Users/administrator/Library/ApplicationSupport/Google/Chrome/NativeMessagingHosts /Applications/Google_Chrome.app/Contents/Profile/NativeMessagingHosts
}
fi
softlink_exists_with_spaces "/Applications/Google Chrome.app/Contents/Profile/NativeMessagingHosts"
}
function app_support_vars(){
APP_SUPPORT_PATCHED="${HOME}/Library/ApplicationSupport"
NATIVE_SUPPORT_PATCHED="${APP_SUPPORT_PATCHED}/Google/Chrome/NativeMessagingHosts"
}
directory_exists_with_spaces "/Applications/Google Chrome.app"
if [ ! -e /Applications/Google\ Chrome.app ] ; then
{
failed Google Chrome is not installed /Applications/Google\ Chrome.app
exit 1
}
fi
app_support_vars
if ( ! softlink_exists "${APP_SUPPORT_PATCHED}" ) || ( ! directory_exists "${NATIVE_SUPPORT_PATCHED}" ) || ( ! softlink_exists_with_spaces '/Applications/Google Chrome.app/Contents/Profile/NativeMessagingHosts' ) || ( ! directory_exists_with_spaces "${HOME}/Library/Application Support/Google/Chrome/NativeMessagingHosts/" ) ; then
{
patch_chrome_alone_fix
}
fi
say 2. Followup Complete Coherence Fix ---
say this is intended to run from the /Application/__COHERENCE_APP.app/ folder
say it will fail if not
cd "$CURRENTWORKINGDIR"
mkdir -p Contents/Profile
cd Contents/Profile
ensure_rmdir NativeMessagingHosts
softlink_create_source_target $CURRENTWORKINGDIR/Contents/Profile/NativeMessagingHosts "${NATIVE_SUPPORT_PATCHED}"
say Finally
say link here
Comment 4. NATIVE_SUPPORT_PATCHED:$NATIVE_SUPPORT_PATCHED
Comment 5. $CURRENTWORKINGDIR/Contents/Profile/NativeMessagingHosts points to "${NATIVE_SUPPORT_PATCHED}"
#softlink_exists_with_spaces $CURRENTWORKINGDIR/Contents/Profile/NativeMessagingHosts
#softlink_exists_with_spaces "$CURRENTWORKINGDIR/Contents/Profile/NativeMessagingHosts>${NATIVE_SUPPORT_PATCHED}"
if [[ ! -e "${NATIVE_SUPPORT_PATCHED}/NativeMessagingHosts" ]] ; then
{
say unlinking "${NATIVE_SUPPORT_PATCHED}/NativeMessagingHosts"
rm -rf "${NATIVE_SUPPORT_PATCHED}/NativeMessagingHosts"
}
fi
Checking Finally
Comment 6. Check that this app links NativeMessagingHosts to Library
ls -la $CURRENTWORKINGDIR/Contents/Profile/NativeMessagingHosts
Comment 7. Check that Library has not NativeMessagingHosts repeated
ls -la "${NATIVE_SUPPORT_PATCHED}"
say End Ö :D