[Linux] Bash script: adding the modding patch to Vivaldi installations
-
What happens in Manjaro if you start the patch script with:
sudo ./PatchVivaldi.sh ~/VivaldiPatch
-
@gwen-dragon Ah, thanks...
[steffie@Tower etc]$ sudo cat /etc/sudoers [sudo] password for steffie: ## sudoers file. ## ## This file MUST be edited with the 'visudo' command as root. ## Failure to use 'visudo' may result in syntax or file permission errors ## that prevent sudo from running. ## ## See the sudoers man page for the details on how to write a sudoers file. ## ## ## Host alias specification ## ## Groups of machines. These may include host names (optionally with wildcards), ## IP addresses, network numbers or netgroups. # Host_Alias WEBSERVERS = www1, www2, www3 ## ## User alias specification ## ## Groups of users. These may consist of user names, uids, Unix groups, ## or netgroups. # User_Alias ADMINS = millert, dowdy, mikef ## ## Cmnd alias specification ## ## Groups of commands. Often used to group related commands together. # Cmnd_Alias PROCESSES = /usr/bin/nice, /bin/kill, /usr/bin/renice, \ # /usr/bin/pkill, /usr/bin/top # Cmnd_Alias REBOOT = /sbin/halt, /sbin/reboot, /sbin/poweroff ## ## Defaults specification ## ## You may wish to keep some of the following environment variables ## when running commands via sudo. ## ## Locale settings # Defaults env_keep += "LANG LANGUAGE LINGUAS LC_* _XKB_CHARSET" ## ## Run X applications through sudo; HOME is used to find the ## .Xauthority file. Note that other programs use HOME to find ## configuration files and this may lead to privilege escalation! # Defaults env_keep += "HOME" ## ## X11 resource path settings # Defaults env_keep += "XAPPLRESDIR XFILESEARCHPATH XUSERFILESEARCHPATH" ## ## Desktop path settings # Defaults env_keep += "QTDIR KDEDIR" ## ## Allow sudo-run commands to inherit the callers' ConsoleKit session # Defaults env_keep += "XDG_SESSION_COOKIE" ## ## Uncomment to enable special input methods. Care should be taken as ## this may allow users to subvert the command being run via sudo. # Defaults env_keep += "XMODIFIERS GTK_IM_MODULE QT_IM_MODULE QT_IM_SWITCHER" ## ## Uncomment to use a hard-coded PATH instead of the user's to find commands # Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" ## ## Uncomment to send mail if the user does not enter the correct password. # Defaults mail_badpass ## ## Uncomment to enable logging of a command's output, except for ## sudoreplay and reboot. Use sudoreplay to play back logged sessions. # Defaults log_output # Defaults!/usr/bin/sudoreplay !log_output # Defaults!/usr/local/bin/sudoreplay !log_output # Defaults!REBOOT !log_output ## ## Runas alias specification ## ## ## User privilege specification ## root ALL=(ALL) ALL ## Uncomment to allow members of group wheel to execute any command # %wheel ALL=(ALL) ALL ## Same thing without a password # %wheel ALL=(ALL) NOPASSWD: ALL ## Uncomment to allow members of group sudo to execute any command # %sudo ALL=(ALL) ALL ## Uncomment to allow any user to run sudo if they know the password ## of the user they are running the command as (root by default). # Defaults targetpw # Ask for the password of the target user # ALL ALL=(ALL) ALL # WARNING: only use this together with 'Defaults targetpw' ## Read drop-in files from /etc/sudoers.d ## (the '#' here does not indicate a comment) #includedir /etc/sudoers.d [steffie@Tower etc]$
-
@gwen-dragon Oooooh, you are a champion dragoness indeed!!
[steffie@Tower VivaldiPatch]$ sudo ./PatchVivaldi.sh ~/VivaldiPatch [sudo] password for steffie: --------------------- Installations found: /opt/vivaldi: 1 /opt/vivaldi-snapshot: 2 Select installation to patch. Input number and press [Enter] or [X] to cancel. Input selection: 2 --------------------- Patch originating from /home/steffie/VivaldiPatch targeting /opt/vivaldi-snapshot browser.html has already been patched! copying custom.css copying custom.js [steffie@Tower VivaldiPatch]$
Thanks so much Lilo
-
I guess sudo has a bug in Manjaro or special default setting which does not pass the callers $HOME variable.
A quick search in web showed me some issues for program sudo, but i did not investigate more (missing spare time)!You can see what sudo allows for users with:
sudo -l -U username
-
missing spare time
... yes, sorry to have stolen it from you ... many thanks for your generosity.
[steffie@Tower ~]$ sudo -l -U steffie [sudo] password for steffie: User steffie may run the following commands on Tower: (ALL) ALL [steffie@Tower ~]$
Anyway, i'm extremely happy with this outcome Lilo. Running your script in future with that simple little extra bit is easy & works great.
Now, get back to work, you idler !!!
-
Hier mal wie sich sudo su und sudo -i unter manjaro verhalten.
[ 14:29 ] [ rolf@hongkong:~ ] $ sudo -i [hongkong ~]# pwd /root [hongkong ~]# Abgemeldet [ 14:29 ] [ rolf@hongkong:~ ] $ sudo su [hongkong rolf]# pwd /home/rolf
sprich sudo -i wird unter manjaro nicht funktionieren.
-
@rocknrolf Do you know why $HOME of caller is not passed to bash script on Manjaro after sudo?
Has Manjaro some special Default env_* settings in sudoers?
-
@gwen-dragon said in [Linux] Bash script: adding the modding patch to Vivaldi installations:
Do you know why $HOME of caller is not passed to bash script on Manjaro after sudo?
Has Manjaro some special Default env_* settings in sudoers?No the sudoers file seems to be "normal".
-
@rocknrolf Perhaps some changes in sudo cause this: See https://www.sudo.ws/stable.html
-
@gwen-dragon Please, where is the Version for Windows?
-
-
Hello guys, just wanted to share a new version I did of this script. I uploaded this together with my custom.js and custom.css to a repo in https://github.com/gregodadone/vivaldi-simple-ui. Special thanks to @Gwen-Dragon and @Christoph142 because I used your ideas to create it. Feel free to modify as you want or make suggestions to make it better.
#!/bin/bash ############################################################### # Author: Grego Dadone # License: GPL V3 ############################################################### # Script to automatically patch Vivaldi browser UI in Linux # Tested on Vivaldi 2.1.1337.36 on 2018-10-29 ############################################################### function checkRoot() { if [ $UID -ne 0 ]; then echo "This script must be run as superuser" sudo $0 #Runs itself as root exit 0 fi } function checkVivaldiInstalled() { vivaldiInstallations=$(find /opt -name vivaldi-bin) vivaldiInstallationsCount=$(echo $vivaldiInstallations | wc -w) if [ $vivaldiInstallationsCount -eq 0 ]; then echo "Could not find any Vivaldi installation" exit 1 fi } function checkModFilesPresent() { if ! [ -f custom.css ]; then echo "Could not find file 'custom.css'" exit 1 fi if ! [ -f custom.js ]; then echo "Could not find file 'custom.js'" exit 1 fi } function selectVivaldiInstallation() { vivaldiInstallationsFolders=($(dirname $vivaldiInstallations)) if [ $vivaldiInstallationsCount -gt 1 ]; then option=0 while [ $option -le 0 ] || [ $option -gt $vivaldiInstallationsCount ]; do echo "Pick Vivaldi installation to patch" i=1 for vivaldiInstallationsFolder in ${vivaldiInstallationsFolders[@]}; do echo "$((i++))) $vivaldiInstallationsFolder" done echo "$i) Cancel" read option #This block transforms input into an invalid option to avoid breaking the script if we enter a letter or a symbol if [[ $(echo $option | egrep '\b[0-9]{1,2}\b') = '' ]]; then option=0 fi #If we choose to cancel we get in here if [ $option -eq $i ]; then exit 0 fi done targetDir=${vivaldiInstallationsFolders[--option]} # the -- operator is to pick correct array index else targetDir=${vivaldiInstallationsFolders[0]} fi } function patchVivaldi() { alreadyPatched=$(grep "custom.css" $targetDir/resources/vivaldi/browser.html); if [[ $alreadyPatched == '' ]]; then #Backup current browser.html cp $targetDir/resources/vivaldi/browser.html $targetDir/resources/vivaldi/browser-$(date +%Y-%m-%dT%H-%M-%S).html #Copy mod files cp custom.css $targetDir/resources/vivaldi/style/ cp custom.js $targetDir/resources/vivaldi/ #Patch browser.html sed -i -e 's/<\/head>/ <link rel="stylesheet" href="style\/custom.css" \/>\n <\/head>/' "$targetDir/resources/vivaldi/browser.html" sed -i -e 's/<\/body>/ <script src="custom.js"><\/script>\n <\/body>/' "$targetDir/resources/vivaldi/browser.html" echo -e "\nVivaldi patched successfully!" else echo "This Vivaldi installation is already patched" fi } checkRoot checkVivaldiInstalled checkModFilesPresent selectVivaldiInstallation patchVivaldi
-
In this script i can only use one custom.css and one custom.js file. What to do hen there are multiple files.
I'm trying to install betterNotes Mod ehich have 5 files.