Nixgeek

Random Ramblings

Adding an existing project to a Git repo

Just a quick tip for creating a new repo with existing files.

  1. Create a new repo on your preferred solution (I use Bitbucket but the other main choice is Github, it’s all about what works for you)

  2. Change to your project directory > cd ~/git/project

  3. Initialize the local directory as a repo > git init

  4. Add all files to the repo > git add .

  5. Write your first commit message > git commit -m ‘First commit’

  6. Tie your local files and remote repo together. For the url, an example would be ssh://git@bitbucket.org/daevien/nixgeek.git, but the method to find it varies depending on your provider. Bitbucket shows it at the top of the main page and GitHub shows it along the right side. > git remote add origin repo_url_here

  7. Have git verify it can connect to the remote repo > git remote -v

  8. Push your initial commit to the remote url > git push origin master

Thats it, your repo is created and initial update complete. Now to continue your content and update it as needed.

How to install RepoForge (formerly RPMForge) on CENTOS 7

As I get back into using CENTOS, I will be posting a few guides on various things I find. One of the first things is to install RepoForge (formerly RPMForge) to give a number of programs such as htop that I really missed.

So, to get started, download this rpm:

wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm

The next step is to install it:

rpm -ivh rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm

And finally, update yum

yum update

And the repo is now installed and updated, feel free to install any packages you need.

Quick password generator

Just a quick little password generator, since I’ve had a couple people ask. It will generate 12 character passwords using a-z, A-Z. 0-9 and various symbols such as _ and -

tr -dc a-zA-Z0-9_- < /dev/urandom | head -c 12 | xargs

Thats it, short and simple but effective.

How to delete an EFI partition in Windows

Just the other day I had to repartition an external drive that had an EFI partition on it. It took a few minutes to figure it out so I thought I’d leave this here for myself and anyone else that might stumble upon the post. Disclaimer of course is that please be sure on which disk and partition you are picking in the following steps so you don’t remove the wrong one and lose data.

Make sure the drive in question is connected and then:

Open a command prompt with elevated permission

Run diskpart

To see all of your disks, type list disk

To select the disk, select disk #

Then select the partition with select partition #

And the last command to run is delete partition override

Now you can close diskpart and the command prompt. The EFI partition is gone :)

Employee Survey

Dilbert

Interesting timing on this one as I just left a job like that around that time :)

Hack.me - Vulnerable web app community

Hack.me is a free community project where people can build, share & host vulnerable web apps to learn and experiment. Each app is sandboxed for you so you are somewhat safe (as safe as you can be on a site with people uploading strange things for security people to break anyway). You can also upload private images for self use. It looks liek a handy tool for anyone interested in learning more about security and penetration testing.

How to configure dropbox for multiple users on a headless Debian / Ubuntu server

There are numerous guides around to configure Dropbox on a headless Debian or Ubuntu server but it seems everytime I go to do one, I can’t find the nice guide I usually use or a website is down when I look for alternatives. So here is my quick guide for myself and anyone else that might stumble upon this page :)

For 32bit:

wget -O dropbox.tar.gz https://www.dropbox.com/download?plat=lnx.x86

tar xzf dropbox.tar.gz

./.dropbox-dist/dropboxd

For 64bit:

wget -O dropbox.tar.gz https://www.dropbox.com/download?plat=lnx.x86_64

tar xzf dropbox.tar.gz

./.dropbox-dist/dropboxd

At this point, dropbox will complain about not being linked to an account and output a web address to follow, do that and login to your account and it will be linked.

Kill the dropbox that you started manually (requires pgrep, if you don’t have it you can use your favorite method):

kill $(pgrep dropbox)

You can repeat the above steps for each user you want to have with their own dropbox.

For older versions of Debian pre-systemd: As root, either download this startup script or copy & paste the following code to /etc/init.d/dropbox and edit the DROPBOX_USERS line as needed:

# dropbox service
DROPBOX_USERS="user1 user2"

DAEMON=.dropbox-dist/dropboxd

start() {
    echo "Starting dropbox..."
    for dbuser in $DROPBOX_USERS; do
        HOMEDIR=`getent passwd $dbuser | cut -d: -f6`
        if [ -x $HOMEDIR/$DAEMON ]; then
            HOME="$HOMEDIR" start-stop-daemon -b -o -c $dbuser -S -u $dbuser -x $HOMEDIR/$DAEMON
        fi
    done
}

stop() {
    echo "Stopping dropbox..."
    for dbuser in $DROPBOX_USERS; do
        HOMEDIR=`getent passwd $dbuser | cut -d: -f6`
        if [ -x $HOMEDIR/$DAEMON ]; then
            start-stop-daemon -o -c $dbuser -K -u $dbuser -x $HOMEDIR/$DAEMON
        fi
    done
}

status() {
    for dbuser in $DROPBOX_USERS; do
        dbpid=`pgrep -u $dbuser dropbox`
        if [ -z $dbpid ] ; then
            echo "dropboxd for USER $dbuser: not running."
        else
            echo "dropboxd for USER $dbuser: running (pid $dbpid)"
        fi
    done
}


case "$1" in
  start)
    start
    ;;

  stop)
    stop
    ;;

  restart|reload|force-reload)
    stop
    start
    ;;

  status)
    status
    ;;

  *)
    echo "Usage: /etc/init.d/dropbox {start|stop|reload|force-reload|restart|status}"
    exit 1

esac

exit 0

After that, you need to make it executable and add it to system startup:

sudo chmod +x /etc/init.d/dropbox

sudo update-rc.d dropbox defaults

Repeat the starting, linking & killing steps above for all of the accounts you want to link. Once that is done run the dropbox init script you copied above:

sudo /etc/init.d/dropbox start

For newer Debian versions with systemd, create a file named /lib/systemd/system/dropbox@.service with the following content:

[Unit]
Description=Dropbox as a system service
After=local-fs.target network.target

[Service]
Type=simple
ExecStart=/usr/bin/env "/home/%i/.dropbox-dist/dropboxd"
Restart=on-failure
RestartSec=1
User=%i

[Install]
WantedBy=multi-user.target

After this, simply run

sudo systemctl enable dropbox@username

sudo systemctl start dropbox@username

And now you should be done. If you want to confirm that multiple dropbox accounts are running you can do:

ps aux | grep -i dropbox