I accidentally added an 'exit' in my CloudShell .bashrc, cannot get back to edit it, it exits immediately - google-cloud-shell

While learning about/customizing my GCP Cloud Shell startup environment I inadvertently added an 'exit' in my .bashrc and now cannot even get the shell up long enough to reset it when I click on the Cloud Shell icon from GCP dashboard -- how to reset it now? I really can't do anything to fix as Cloud Shell exits immediately trying to start up.

You can use gcloud alpha cloud-shell ssh with the option --command to rename the file as suggested in the comments to the question, or to simply sed that line out of existence.

The correct way to solve this is to enter Cloud Shell in safe mode. This will log you into Cloud Shell as root, allowing you to fix any issues with your regular user account.

OK, I fixed it. Solution is to click very quickly on the 'Editor' icon in top right of initial Cloud Shell window when it tries to open giving you a file list of your home directory which is stable and will stay open. Then go to 'Edit', 'Find in Files' and, in my case, search for 'exit'. But to find in hidden files such as .bashrc you need also to click the little eye icon to 'Include Ignored Files'. Edit, exit and restart a Cloud Shell instance and you're good.

Related

I have a problem with the db_assembler. bash mysqladmin not found

even so I can access my sql database, seeing it running in my services and created the user acore with all rights I have this error when using db_assembler.
https://i.imgur.com/Xf51U0J.png
Then the window gets closed I configured the config.sh earlier but it didnt got me far. Thanks for the help.
Just ran into the same problem, and solved by editing the Path variable in Windows. The error is caused because the 'mysqladmin.exe' file is not being found by the AzCore installation script.
To fix it, you need to add the directory that file is found in (usually C:\Program Files\MySQL\MySQL Server 8.0\bin\ on a default install) to the Path variable. To do that, go to Advanced System Settings under System in the Control Panel, click the Environment Variables button, select Path from the list up the top, and click the Edit button. Then click New, add the path to the 'mysqladmin.exe' file, and OK out of there. You'll need to reboot, restart the MySQL Server service, and then retry the AzCore DB installation script.

R: reload google chrome URL if already loaded

I am using an Rscript to load an .html file with Google Chrome via browseURL("myfile.html"). However, I would like the Rscript to first check if the URL is already open in Chrome, and if so, just reload the URL. I don't want it to open the URL in a new Chrome tab. Is there a way to achieve this?
You can get to work with the help of some third-party components.
When you call Rscript's browseURL function, it's just running whatever program it thinks is the browser and passing it your URL. You can tell it to use whatever "browser" you want:
browseURL("file:/path/to/my/file.html",
browser = "/path/to/chrome_reloader.sh")
You can use the Chromix Too package to control Chrome. You will have to install a few things, but it's easy and only takes a few minutes:
Install the Chromix Too extension from the Chrome web store.
Install the latest version of NodeJS.
Use npm (installed with NodeJS) to install Chromix Too.
Run the Chromix Too server.
Now you run commands like chromix-too ls to see a list of all the tabs you have open in Chrome and chromix-too reload http://some.web.site/ to reload one of them.
Now you can write the chrome_relauncher.sh script that just passes whatever URL it gets to chromix-too reload:
#!/bin/bash
chromix-too reload $1
It looks like reload only reloads a tab that already exists but won't open a new one. You could use the ls command to first check if the tab exists; it looks like chromix-too ls 'http://some.site/path' returns success (0) if the tab exists and failure (1) if it doesn't, so you could use that in your script. Or just open the tab manually before running your Rscript program. There's also a file command that loads a local file and specifically says it will reuse and reload an existing tab.
You may need to tweak a few things (maybe add the path to chromix-too which you can get with which chromix-too) but this should basically work.

How to remember password in FortiClient VPN? [closed]

Closed. This question is not about programming or software development. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 months ago.
The community reviewed whether to reopen this question 3 months ago and left it closed:
Original close reason(s) were not resolved
Improve this question
The last version of FortiClient asks me about my password every time.
How can I make the program to remember it and who faces a similar problem?
Does anyone have a solution?
Open FortiClient console.
Press button Backup in System section.
Save your configuration in vpn.conf file (No password).
Open vpn.conf in text editor.
Find string: "show_remember_password" type="4" data="0"
Modify to: "show_remember_password" type="4" data="1"
Save changes.
Press button Restore in System section FortiClient console.
Select your changed vpv.conf file.
Now you can see Save Password checkbox and you can save your password.
I had the same issue in OSX (Sierra) using Forticlient 5.4.1.I ended up editing the following file:
[May be in a different location for you depending how app was installed - look at long answer below if it doesn't exist]
sudo vim /Library/Application\ Support/Fortinet/FortiClient/conf/vpn.plist
To change the following two zeroes to ones:
...
<dict>
<key>YOUR_VPN_CONNECTION_NAME_HERE</key>
<dict>
<key>AllowAutoConnect</key>
<integer>1</integer>
<key>AllowKeepRunning</key>
<integer>0</integer>
<key>AllowSavePassword</key>
<integer>1</integer>
...
Save and then simply open again and the checkboxes to save will be available now, unlike before.
You could also use the same thing to save some vpn settings for auto rollout of machines by script (instead of manual setup for each user)
For those interested, the way I found it was simple:
Open Forticlient Console
In terminal run "sudo opensnoop | grep Forti"
In forticlient console quickly add a new vpn
(CNTl-C) terminal and then search through output
File above was most obvious sounding one and quick look showed a good outlook.
Edit as above and it works.
According to the official documentation, "How to activate Save Password, Auto Connect, and Always Up in FortiClient", the availability of this option (and some others) is decided by the server administrator, using the config setting set save-password enable.
You can currently override this by tampering with the show_* options in the registry; specifically,
HLKM\Software\Wow6432Node\Fortinet\Forticlient\sslvpn\<name>\show_remember_password = 1
Then if 'save password' is checked during login, the client will encrypt the password into the DATA1 and DATA2 values, and even though the server may hide the checkboxes again, the saved password will stay. To clear it, edit the connection's settings and switch auth back to 'Prompt on login'.
EDIT: As posted by Igor half a year later, a much more structured solution is to export the config file, alter it and then load it back in. There are various useful settings you might want to tweak. You can also re-use the config file when deploying to multiple hosts or re-installing.
For windows and Forticlient VPN (Not only named Forticlient) 6 or above version:
Open the FortiClient.
Press the config symbol.
Press the button Backup.
Save your configuration in vpn.conf file.
Open your vpn.conf in text editor.
Find the string: show_remember_password (it must be 0)
Modify to: 1
Find the string again show_remember_password under user_configuration.
Modify to: data="1"
Save changes.
Find button Restore under config again.
Firstly, click lock icon(this button enable to restore operation) and then click restore.
Select your changed vpn.conf file. Now you can see Save Password checkbox and you can save your password.
This checkbox may be disappear after first using. Don't worry, if your password changes, do it again these steps.
FortiClient 6.4: In Windows regedit, go to
Computer\HKEY_CURRENT_USER\SOFTWARE\Fortinet\FortiClient\Sslvpn\Tunnels\<vpn name>
and set the value of show_remember_password to 1.
For Linux you may use forticlientsslvpn_cli with Expect to feed in the password.
A complete solution available here:
https://gist.github.com/azizasm/e216bc47b54f5b68405f3c8f8b832e8a
Note: this solution will auto reconnect the if the VPN get disconnected.
I have tried editing the configuration file and restoring but the switch resets itself after a connection has been made as described above.
I have also edited the registry at Computer\HKEY_CURRENT_USER\SOFTWARE\Fortinet\FortiClient\Sslvpn\Tunnels<vpn name> to ensure a key SavePass exists with a value of 1 but that also does not persist.
This is on version 6+ of Forticlient.
However on version 5.2.5.0658 I found that editing the config file AND editing the vpn connection details and removing the 'Description' field I can then enter a password and tick the save password. This is remembered after disconnecting and persists provided you don't shutdown Forticlient.
in Windows, if you use register editor, and search
HKEY_CURRENT_USER\SOFTWARE\Fortinet\FortiClient\Sslvpn\Tunnels<VPN_NAME>, you'll se a show_remember_password entry with a value of "0". If you change this value to "1", you will be able to save your password for latter use...
For FortiClient VPN 6.4.3, seems like you have to
modify the user configuration section within the *.conf" file or
add a save_password node to the ui section in your *.conf file.
I'll detail option 1.:
Open FortiClient VPN
Export your *.conf file:
Click the gear icon (second icon) on the upper-right
Click Backup
In the file dialog box, indicate the file to output your *.conf
Ensure the "Include user settings" is checked
Indicate a password for encrypting the *.conf file. This password is used simply to encrypt sensitive info for exporting/importing the *.conf file.
Open the *.conf file in a text editor.
7 At the bottom of the file, in the user_configuration section, set show_remember_password key to 1:
Save the *.conf file.
Import your *.conf file:
Click the padlock icon on the upper-right. This must be done to Restore *.conf file
Click the Restore button
Indicate the File and password (used to encrypt the *.conf file in the 'Export conf file' section)
Click OK
This did the trick for me. Also, it appears once this was done, a "save_password" element was added to the conf file, if exported again: connections > connection > ui section of the *.conf file, with a value of 1:
<ui>
<show_alwaysup>0</show_alwaysup>
<show_autoconnect>0</show_autoconnect>
<save_username>0</save_username>
<save_password>1</save_password>
<show_remember_password>0</show_remember_password>
</ui>

DirCopy() Not Working

I'm working in AutoIT to script a basic task I'll have to repeat on 50ish workstations.
I need to copy a directory and it's subdirectories and files (recursively) to a network share as a backup. For some reason, DirCopy() does not work at all.
I've tried running it on several different directories (thinking permissions issue, I'm Domain Admin account), tried doing a RunAs (again thinking permissions), and also put the #RequireAdmin tag to force the program to run on an elevated account. Nothing has worked. I can't even get it to copy empty directories.
DirCopy(#DesktopDir & "\SAMPLE\TEST1", #DesktopDir & "\SAMPLE\TEST2", 0)
Please advise!
Just figured this one out.
Turns out DirCopy() is a pretty stupid function that cannot handle if the destination directory already exists (it wants to create it for you). So if you kill the destination directory, then run the above code line, all woks as expected. But then if you add a new file into the source directory (TEST1 in my example), then it breaks again and does nothing.
Go figure...
Now time to find a work-around using something like xcopy...

Is it possible to flush all image module directories in Drupal 7?

Is there a way to flush all of the image directories at once? Perhaps using Drush?
Also, from the command line, with drush installed:
drush image-flush
which gives you a drop-down of all catagories. Choose 'all'!
I've done this on my system, but make sure you back it up when you test it out yourself.
Simply delete the styles directory in your files directory. They will re-create as they are loaded.
i.e. from the command line, from your web root, you would run:
$ rm -rf sites/default/files/styles
You may run into permission issues as those files will be owned by the web user. In that case, maybe you could have a form & submit handler in a module delete those files since that would be run by the web user. That is another topic though.

Resources