-
Cloning a git repository in an idempotent way
This blog post is useless due to the advent of the smart git protocol. Since sites using the "dumb protocol" are becomming rare this post has limited, if any, use.Posted 12-07-2015 at 01:48 PM by sag47 -
Cloning a git repository in an idempotent way
I was thinking of attempting parsing the default branch with the following.
Code:git ls-remote origin | awk '$2 == "HEAD" { head=$1; next}; $1 == head && $2 ~ /^refs\/heads/ {sub(/refs\/heads\//, "",$2);print $2}'
Posted 05-20-2015 at 02:19 AM by sag47 -
Batch convert images to PDF
My examples listed above are a pile of crap. Here's a better way of doing the above.
For JPG images,
Code:for x in *.jpg;do convert "${x}" "${x%.jpg}.pdf";done
Posted 08-03-2013 at 09:50 AM by sag47 -
SELinux and Icinga
Recently I compiled icinga-web. It requires the following security contexts to be appended to /etc/selinux/targeted/contexts/files/file_contexts.local
Code:/usr/local/icinga-web/app(/.*)? system_u:object_r:httpd_sys_content_t:s0 /usr/local/icinga-web/lib(/.*)? system_u:object_r:httpd_sys_content_t:s0 /usr/local/icinga-web/pub(/.*)? system_u:object_r:httpd_sys_content_t:s0 /usr/local/icinga-web/app/cache(/.*)? system_u:object_r:httpd_sys_rw_content_t:s0 /usr/local/icinga-web/log(/.*)? system_u:object_r:httpd_sys_rw_content_t:s0
Code:restorecon -R /usr/local/icinga-web
Posted 04-16-2013 at 11:00 PM by sag47 -
SELinux and Icinga
I forgot to mention but in my previous comment once I created the security contexts for Icinga I used the restorecon command on those three folders so that they work with SELinux.
Code:restorecon -R /usr/local/icinga/sbin restorecon -R /usr/local/icinga/share restorecon -R /usr/local/icinga/var
Posted 01-13-2013 at 10:57 PM by sag47 -
Using a script to get your IP address
Thanks . I was discussing it with my local LUG mailing list and here's a good solution they came up with which will present the IP address of the default route (I substituted some of their cuts with awk instead).
Code:ip -o ro get $(ip ro | awk '$1 == "default" { print $3 }') | awk '{print $5}'
Code:sed -ne '/^eth2/,/^\s\+Interrupt/p'
Posted 01-08-2013 at 04:35 PM by sag47 -
Using a script to get your IP address
Save two commands, get more awk for free:
Code:/sbin/ifconfig | awk '/inet addr:/ {if ($2 !~ "127.*") print substr($2,6)}'
Posted 01-07-2013 at 06:32 PM by unSpawn -
SELinux and Icinga
Here's the now recommended way of managing file_contexts.local using the semanage utility.
Code:semanage fcontext -a -t httpd_sys_script_exec_t '/usr/local/icinga/sbin(/.*)?' semanage fcontext -a -t httpd_sys_content_t '/usr/local/icinga/share(/.*)?' semanage fcontext -a -t httpd_sys_rw_content_t '/usr/local/icinga/var(/.*)?'
Warning: The rest of the comment is the old method of manually editing file_contexts.local. I left it for documentation purposes however you should execute the semanage commands I outlined above.
I added the following lines to /etc/selinux/targeted/contexts/files/file_contexts.local
Code:/usr/local/icinga/sbin(/.*)? system_u:object_r:httpd_sys_script_exec_t:s0 /usr/local/icinga/share(/.*)? system_u:object_r:httpd_sys_content_t:s0 /usr/local/icinga/var(/.*)? system_u:object_r:httpd_sys_rw_content_t:s0
Posted 08-23-2012 at 11:13 PM by sag47
Updated 06-18-2013 at 09:14 AM by sag47 -
SELinux, syslog-ng, and the like
Note, setroubleshoot-server continued to be noisy on my server. After some research I found that setroubleshoot-server sends email alerts on AVC denies and other SELinux warnings. However, for a server it's not necessary to have installed.
I removed it to cut down on log noise because I don't care if something gets denied. Let me rephrase that, I don't need to be emailed every time SELinux denies something because I won't change the security to allow certain things.
Removed packages include:- setroubleshoot-server
- setroubleshoot (depends on setroubleshoot-server)
- setroubleshoot-plugins (depends on setroubleshoot-server)
Posted 06-19-2012 at 10:23 AM by sag47
Updated 06-19-2012 at 10:25 AM by sag47 -
Monitoring sound over time for long periods to see trends using a microphone
Thanks unSpawn for an emailed patch which creates more secure temporary files. Here's his code after applying the patch.
Code:#!/bin/sh case $1 in config) cat <<EOM graph_title Sound Amplitude graph_args -l -1 --upper-limit 1 graph_vlabel Amplitude graph_info Shows the sound amplitude values during the 1 second interval recorded discretely every minute. mxamp.label max_ampl mxamp.info Maximum amplitude mnamp.label min_ampl mnamp.info Minimum amplitude mdamp.label mid_ampl mdamp.info Midline amplitude EOM exit 0;; esac LANG=C; LC_ALL=C; export LANG LC_ALL; MYTMPDIR=`mktemp -p /tmp -d ampl.XXXXXXXXXX` && { arecord -d 1 -f cd -t wav "${MYTMPDIR}/foo.wav" &> /dev/null echo -n "mxamp.value " sox "${MYTMPDIR}/foo.wav" -n stat 2>&1 | awk '/Maximum amplitude/ {print $3}' echo -n "mnamp.value " sox "${MYTMPDIR}/foo.wav" -n stat 2>&1 | awk '/Minimum amplitude/ {print $3}' echo -n "mdamp.value " sox "${MYTMPDIR}/foo.wav" -n stat 2>&1 | awk '/Midline amplitude/ {print $3}' rm -rf "${MYTMPDIR}" } exit 0
SAMPosted 06-12-2012 at 09:52 AM by sag47
Updated 06-12-2012 at 11:09 AM by sag47 -
DVD Ripping
I found a nice solution for lossless encoding using ffmpeg. I think I like it more than use mencoder.
Code:ffmpeg -i VTS_01_1.VOB -acodec libfaac -aq 100 -ac 2 -ab 128k -vcodec libx264 -vpre lossless_medium -threads 4 video.mp4
For the video quality I used some preinstalled presets.
Quote:Originally Posted by ffmpeg man pageCode:If no such file is found, then ffmpeg will search for a file named codec_name-arg.ffpreset in the above-mentioned directories, where codec_name is the name of the codec to which the preset file options will be applied. For example, if you select the video codec with "-vcodec libx264" and use "-vpre max", then it will search for the file libx264-max.ffpreset.
/usr/share/ffmpeg/libx264-lossless_medium.ffpreset
The -threads means that it will encode the video taking advantage of multiple cores on a system. I have four processing cores so I set threads to 4 (-threads 4).
Sources:
http://superuser.com/questions/22777...on-with-ffmpeg
http://ubuntuforums.org/showthread.php?t=1564791
I got ffmpeg for Fedora 16 from these repositories.
Code:rpm -Uvh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm rpm -Uvh http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm
Code:ffmpeg -codecs
Posted 06-11-2012 at 08:19 PM by sag47
Updated 06-11-2012 at 08:32 PM by sag47 -
Convert and resize images using imagemagick
Just resized pictures 25% smaller and used a better way to change extensions which I outlined in this thread.
Code:for x in *.JPG;do convert -resize 25% $x processed/${x%.JPG}.jpg;done
Posted 03-03-2012 at 05:28 PM by sag47
Updated 03-03-2012 at 05:32 PM by sag47 -
SELinux and sshd
I probably should have mentioned this but if you have the
Code:AllowGroups wheel
Here's an example of adding a user who can't ssh and then adding that user to a group so they can ssh.
Code:adduser test usermod -a -G wheel test
Posted 01-03-2012 at 10:14 PM by sag47
Updated 01-03-2012 at 10:15 PM by sag47 -
openbox and repeating keys
Unfortunately this appears to break when using Synergy. Switching away from the screen and back seems to cause the xset command to disable. By disable I mean you have to run the xset r on command again for it to work again. But switching screens will turn it off every time.Posted 12-12-2010 at 01:15 PM by sag47