I'm trying to install and be able to run rabbitmqadmin on a linux machine. Following the instructions described here do not help.
After downloading the file linked, it prompts to copy the file (which looks like a python script) into /usr/local/bin.
Trying to run it by simply invoking rabbitmqadmin results in rabbitmqadmin: command not found. There seems to be no information anywhere about how to get this to work and assumes that all the steps listed on the site should work for all. It seems odd that simply copying a python script to the bin folder should allow it to become a recognised command without having to invoke the python interpreter every time.
Any help is appreciated.
I spent several hours to figure out this, use rabbitmqadmin on linux environment, Finally below steps solve my issue.
On my ubuntu server, python3 was installed, I checked it using below command,
python3 -V
Step 1: download the python script to your linux server
wget https://raw.githubusercontent.com/rabbitmq/rabbitmq-management/v3.7.8/bin/rabbitmqadmin
Step2: change the permission
chmod 777 rabbitmqadmin
Step3: change the header of the script as below(first line)
#!/usr/bin/env python3
Thant's all, Now you can run below commands,
To list down queues,
./rabbitmqadmin -f tsv -q list queues
To Delete ques,
./rabbitmqadmin delete queue name=name_of_queue
To add binding between exchange and queue
./rabbitmqadmin declare binding source="exchangename" destination_type="queue" destination="queuename" routing_key="routingkey"
RabbitMQ decided to omit one vital piece of information.
Make the script executable with chmod +x otherwise it will fail to work.
I want to post my commands for installing rabbitmqadmin, it is combination of other answers, but with a little improvements for using best practice:
sudo rabbitmq-plugins enable rabbitmq_management
wget 'https://raw.githubusercontent.com/rabbitmq/rabbitmq-management/v3.7.15/bin/rabbitmqadmin'
chmod +x rabbitmqadmin
sed -i 's|#!/usr/bin/env python|#!/usr/bin/env python3|' rabbitmqadmin
mv rabbitmqadmin .local/bin/
rabbitmqadmin -q list queues
I suppose that you already create .local/bin/ dir and add it to PATH (on Ubuntu bash add this dir to PATH if it exists).
After install Rabbbitmq on Ubuntu/Debian, you can activate the Rabbitmq Admin Portal using the next command:
rabbitmq-plugins enable rabbitmq_management
Then you can access to the portal from http://localhost:15672. Use the user/password "guest".
Below the steps to install rabbimqadmin:
cd /usr/local/bin/
wget http://127.0.0.1:15672/cli/rabbitmqadmin
chmod 777 rabbitmqadmin
For more details check the official documentation Obtaining rabbitmqadmin
Related
I'm trying to connect to my vpn on startup. I normally enter protonvpn c -f into command line.
I have tried the method of creating an rc.local file however it didn't work.
This is the code I have inside of it (I got this from a post about a similar issue):
#!/bin/sh -e
/usr/local/bin/protonvpn c CH-NL#1
exit 0
I also made the file executable with chmod +x.
Im running Kali 2020.1 if that helps.
How do I fix this?
create a file ==> /etc/rc.local
Open and Edit rc.local like below,
replace your command with apt-get update below
#!/bin/sh -e
apt-get update
exit 0
save the edit with Crtl+X
after that
sudo chmod +x /etc/rc.local
then do a reboot and check
It should 100% work like a charm
This solution should work for ubuntu systems.
https://askubuntu.com/a/290107/1051584
Kali is debian based so I believe this will probably work as well.
I am trying to use VSTS to deploy a zip file to a Linux VM in Azure. I am using an SSH task to run the command:
sudo unzip -ju /home/$USER/release/deployfile-1.6.zip "*.war" -d "/opt/tomee/webapps/"
That command works. I don't want to change the filename each time it changes, though. I tried using a variable name:
sudo unzip -ju /home/$USER/release/$filename "*.war" -d "/opt/tomee/webapps/"
And I tried using a wildcard:
cd "/home/$USER/release/"
sudo unzip -ju '*.zip' "*.war" -d "/opt/tomee/webapps/"
(the above is supposed to be star.zip and star.war) Neither of those worked, and having little familiarity with Linux, I haven't been able to figure out a syntax that works.
Could someone please advise? Thank you.
Based on #JNevill comments, I made another attempt at using a variable for the filename. I also changed the u parameter to an o to automatically overwrite files. The final command syntax is:
sudo unzip -jo "/home/$USER/release/$(filename)" "*.war" -d "/opt/tomee/webapps/"
When the command is executed on the remote VM it becomes:
sudo unzip -jo "/home/$USER/release/deployfile-1.6.zip" "*.war" -d "/opt/tomee/webapps/"
The war files were successfully deployed to the VM.
I am using the docker-solr image with docker, and I need to mount a directory inside it which I achieve using the -v flag.
The problem is that the container needs to write to the directory that I have mounted into it, but doesn't appear to have the permissions to do so unless I do chmod 777 on the entire directory. I don't think setting the permission to allows all users to read and write to it is the solution, but just a temporary workaround.
Can anyone guide me in finding a more canonical solution?
Edit: I've been running docker without sudo because I added myself to the docker group. I just found that the problem is solved if I run docker with sudo, but I am curious if there are any other solutions.
More recently, after looking through some official docker repositories I've realized the more idiomatic way to solve these permission problems is using something called gosu in tandem with an entry point script. For example if we take an existing docker project, for example solr, the same one I was having trouble with earlier.
The dockerfile on Github very effectively builds the entire project, but does nothing to account for the permission problems.
So to overcome this, first I added the gosu setup to the dockerfile (if you implement this notice the version 1.4 is hardcoded. You can check for the latest releases here).
# grab gosu for easy step-down from root
RUN mkdir -p /home/solr \
&& gpg --keyserver pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \
&& curl -o /usr/local/bin/gosu -SL "https://github.com/tianon/gosu/releases/download/1.4/gosu-$(dpkg --print-architecture)" \
&& curl -o /usr/local/bin/gosu.asc -SL "https://github.com/tianon/gosu/releases/download/1.4/gosu-$(dpkg --print-architecture).asc" \
&& gpg --verify /usr/local/bin/gosu.asc \
&& rm /usr/local/bin/gosu.asc \
&& chmod +x /usr/local/bin/gosu
Now we can use gosu, which is basically the exact same as su or sudo, but works much more nicely with docker. From the description for gosu:
This is a simple tool grown out of the simple fact that su and sudo have very strange and often annoying TTY and signal-forwarding behavior.
Now the other changes I made to the dockerfile were these adding these lines:
COPY solr_entrypoint.sh /sbin/entrypoint.sh
RUN chmod 755 /sbin/entrypoint.sh
ENTRYPOINT ["/sbin/entrypoint.sh"]
just to add my entrypoint file to the docker container.
and removing the line:
USER $SOLR_USER
So that by default you are the root user. (which is why we have gosu to step-down from root).
Now as for my own entrypoint file, I don't think it's written perfectly, but it did the job.
#!/bin/bash
set -e
export PS1="\w:\u docker-solr-> "
# step down from root when just running the default start command
case "$1" in
start)
chown -R solr /opt/solr/server/solr
exec gosu solr /opt/solr/bin/solr -f
;;
*)
exec $#
;;
esac
A docker run command takes the form:
docker run <flags> <image-name> <passed in arguments>
Basically the entrypoint says if I want to run solr as per usual we pass the argument start to the end of the command like this:
docker run <flags> <image-name> start
and otherwise run the commands you pass as root.
The start option first gives the solr user ownership of the directories and then runs the default command. This solves the ownership problem because unlike the dockerfile setup, which is a one time thing, the entry point runs every single time.
So now if I mount directories using the -d flag, before the entrypoint actually runs solr, it will chown the files inside of the docker container for you.
As for what this does to your files outside the container I've had mixed results because docker acts a little weird on OSX. For me, it didn't change the files outside of the container, but on another OS where docker plays more nicely with the filesystem, it might change your files outside, but I guess that's what you'll have to deal with if you want to mount files inside the container instead of just copying them in.
Hi there does anybody knows how to make an apache2 service to run at startup?
After Kali linux boots up,
I have tried editing rc.local, rc.init and rc file.
Adding
service apache start
command I have also made bash script, giving its permissions to run it with chmod +x b.sh - placed in bin folder for ability to run in anywhere in command line.
I am able to run it in terminal, it does what I need. But can't get it running on start up.
Also I tried:
update-rc.d mystartup.sh defaults 100
still no success. Any ideas?
Thanks.
Place your script inside init /etc/init.d/ , then place a link to it inside /etc/rc5.d/ (be sure to get your accurate run-level)...
Start the second link with the string S71 like S71apastart
I.e do the following:
Place the text:
#!/bin/bash
sudo service apache start
inside /etc/init.d/apaStart (a new file created by you)
Then
sudo chmod +x /etc/init.d/apaStart
sudo ln -s /etc/init.d/tomcat /etc/rc5.d/S71apaStart (change rc5.d to rc3.d if needed depending on your runlevel)
I won't suggest this method but it'll work with your situation.
Okay, I currently use an eggdrop IRC bot on my server. I want to make a bash script to start it up as well as a few other scripts at the same time. All that's left is to make it start, but it won't run as root.
However, I also need to be in the current directory of the file to run it, or it displays an error.
For example:
/home/eggdrop/eggdropbot/eggdrop will display an error, so to run it I need to
cd /home/eggdrop/eggdropbot and then ./eggdrop
So I can't just use "sudo -u eggdrop /home/eggdrop/eggdropbot/eggdrop" and as you probably know, sudo won't cd, either, since that would be pointless.
Any suggestions?
Why not just cd first and then sudo -u ./eggdrop .?
What about doing the cd, and, only then, launch the command with sudo ?
I suppose something like this should do the trick :
cd /home/eggdrop/eggdropbot && sudo -u eggdrop ./eggdrop
You can cd to the directory as the root user and then use sudo -u to invoke the program from the working directory.